on ‎2007 Apr 11 11:21 AM
Hi all,
i have a problem with two jsp pages.
Each jsp page is made using "Create new portal application object."
They use bean to communicate.
In the first one is selected something from a listbox, and the second one have to show what has been selected.
This doesn't work. I mean, i select something, but it is not shown in the other jsp page.
There are located in a Portal page.
If someone can help me with advice? why this doesn't work.
I will give more information if necessary.
Thank you very much in advance.
BR
Request clarification before answering.
Hi,
Make the scope of the bean as "request" and change your object creation of the bean in the java component accordingly. scope "application" will not work between two different components.Hope it helps!
Thanks,
Beevin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i am new on jsp , as u probably has realised
I found one pdf file here in the forum where very nice is described everything,
so maybe it will help me. I saw that there are some minor things, that weren't decribed in the other book, which i read before.
Thank you very much for your help.
Best regards
Diana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, strange, i tested this yesterday, but it didn't work for me.
I will try again, to see if it will work this time. Maybe i haven't done something correct yesterday. That is why i thought that i am not doing it correct.
I will test the two variants and will write back here.
Thank you very much both of you for help.
Best regards.
Diana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you paste your code? Mayb its a prob with the code.
Regards,
Pooja.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
here is the code:
<b><u>listboxbean.java</u></b>
package Exercise4;
import java.io.Serializable;
import com.sapportals.htmlb.DefaultListModel;
public class listboxbean implements Serializable {
public DefaultListModel model;
public String selected;
public DefaultListModel getModel() {
return model;
}
public void setModel(DefaultListModel model) {
this.model = model;
}
// constructor
public listboxbean() {
this.model = new DefaultListModel();
model.addItem("SAP R/3", "SAP R/3");
model.addItem("SAP Portal", "SAP Portal");
model.addItem("SAP BW", "SAP BW");
this.model.setSingleSelection(true);
}
}<u><b>
listdisplay.java</b></u>
package Exercise4;
import Exercise4.listboxbean;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;
import com.sapportals.htmlb.event.*;
import com.sapportals.htmlb.page.*;
import com.sapportals.portal.htmlb.page.*;
import com.sapportals.portal.prt.component.*;
public class listdisplay extends PageProcessorComponent {
public DynPage getPage(){
return new listdisplayDynPage();
}
public static class listdisplayDynPage extends JSPDynPage{
public listboxbean myBeanName = null;
private final static String BEAN_KEY = "myBeanName";
private final static int INITIAL_STATE = 0;
private final static int DISPLAY_SELECT = 1;
private int state = INITIAL_STATE;
public void doInitialization(){
state = INITIAL_STATE;
IPortalComponentContext ctxt = ((IPortalComponentRequest)getRequest()).getComponentContext();
Object o = ctxt.getValue(BEAN_KEY);
if(o==null || !(o instanceof listboxbean)){
myBeanName = new listboxbean();
ctxt.putValue(BEAN_KEY,myBeanName);
} else {
myBeanName = (listboxbean) o;
}
}
public void doProcessAfterInput() throws PageException {
IPortalComponentContext ctxt =
((IPortalComponentRequest)getRequest()).getComponentContext();
myBeanName = (listboxbean) ctxt.getValue(BEAN_KEY);
/* get the listbox by name. */
ListBox lb = (ListBox) this.getComponentByName("SAP_Products");
/* retrieve the selected item*/
myBeanName.selected = lb.getSingleSelection();
}
public void doProcessBeforeOutput() throws PageException {
switch (state) {
case INITIAL_STATE:
this.setJspName("listdisplay.jsp");
break;
case DISPLAY_SELECT:
this.setJspName("displayselect.jsp");
break;
}
}
public void Select (Event event) throws PageException {
/* Handles event from the listbox */
state = DISPLAY_SELECT;
}
}
}
<u><b>listdisplay.jsp</b></u>
<%@ taglib uri= "tagLib" prefix="hbj" %>
<jsp:useBean id="myBeanName" scope="application" class="Exercise4.listboxbean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:textView
id="Products"
text="SAP's software product"
design="EMPHASIZED"
/>
<br>
<hbj:listBox
id="SAP_Products"
tooltip="Select any SAP Products"
size="3"
width="100"
model="myBeanName.model"
onSelect="Select" >
</hbj:listBox>
</hbj:form>
</hbj:page>
</hbj:content>
the page that display the slected from the previous page.
<u><b>displayselect.jsp</b></u>
<%@ taglib uri= "tagLib" prefix="hbj" %>
<jsp:useBean id="myBeanName" scope="application" class="Exercise4.listboxbean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:textView
id="Products"
text="You have selected:"
design="EMPHASIZED"
/>
<br>
<hbj:textView
id="Products"
text="<%=myBeanName.selected%>"
design="EMPHASIZED"
/>
<br>
</hbj:form>
</hbj:page>
</hbj:content>And there is no code located for this jsp file in his java file
Thank you.
BR
Hi,
If you are using 2 iviews then you need to use portal eventing to pass data from one iview to another. Refer this link for more info:
Why are you using 2 components? The easier way is to include both your jsp pages in a single portal component and create one iview out of it.
Regards,
Pooja.
Hi,
If you want only one component, then create a JSPDynPage application. You have option to include bean. A JSP file will be created in pagelet folder. To include another JSP file right click on pagelet folder and select New->Other->J2EE->Web->JSP File. If this doesnt work you can create a .jsp file in your system and copy paste it to your pagelet folder in NDS.
Hope this helps.
Regards,
Pooja.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.