Hi,
I've been struggling with JSPDynpages for a little while now. Basically I just want some sort of semblance to the classical J2EE structure where I click a button and I go on to my next JSP. Here is my JSPDynPage code:
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 testForm extends PageProcessorComponent {
public DynPage getPage(){
return new testFormDynPage();
}
public static class testFormDynPage extends JSPDynPage{
private static int INITIAL_STATE=0;
private static int NEXT_STATE = 1;
public int state = INITIAL_STATE;
public void doInitialization(){
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
if (state == INITIAL_STATE) {
this.setJspName("testForm.jsp");
}
else {
this.setJspName("testForm2.jsp");
}
}
public void onClick(Event event) throws PageException {
state = NEXT_STATE;
}
}
}
Here is testform.jsp:
<%@ taglib uri= "tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId"
method="POST"
action="./testForm2.jsp"
target="_blank">
Press this button to go to the next JSP.
<hbj:button id="formButton"
text="OK"
design="EMPHASIZED"
onClick="onClick"
width="100"
>
<% myFormId.setDefaultButton(formButton); %>
</hbj:button>
</hbj:form>
</hbj:page>
</hbj:content>
And here is testForm2.jsp:
<%@ taglib uri= "tagLib" prefix="hbj" %>
<hbj:content id="myContext2" >
<hbj:page title="PageTitle2">
<hbj:form id="myFormId2" >
This is the next JSP.
</hbj:form>
</hbj:page>
</hbj:content>
Both JSPs reside in the pagelet folder of my PAR. I've created an iView from the PAR by selecting "New From Par" in the Content Studio of EP6. When I preview the iView, I see the first formTest.jsp. When I click the button, I expect to be fowarded to formTest2.jsp but instead another window opens with formTest.jsp (since i have target=_blank).
What am I missing?
Hi Vu,
remove "method, action, target" in <hbj:form> just have <hbj:form id="myFormId" > try with the same program. Are u trying to view from content studio? Try deploying it in portal using Component Manger, and run the iview from Conponent Inspector.
Thanks,
Praveen
Hi Vu,
Life cycle of PageProcessorComponent .
when your class testForm is invoked , first time doInitialization (this will called only once) is executed followed by doProcessBeforeOuput.In this method you can call the firstJSP(testForm) page to be dispalyed. In that JSP for FORM control you dont need to specify any property like action or method. instead say onclick = "submit" for Button control which will call the doProcessAfterInput followed by OnSubmit method where the state is changed and followed by doProcessBeforeOuput where the state is checked and directed to the corresponding JSP.
Hope this helps.
Sujatha
Hi Praveen,
Ok, I'm reverting back to a simple example that still doesn't work for me. It's the JSPDynPage Example that prints out "May the force be with you..."
I get null values in the first and second JSP. It seems like the bean is just not communicating with the JSP. I have copied exactly what the example code has. I build my project in NWDS and then deploy via NWDS. I then go to the Content Studio and select new from Par and create a new iView to launch my DynPage.
When I click the button , I get, "The force is with you null".
Without this fundamental communication working, I cannot move on.
Thanks!
I had a problem with the jsp not talking to the bean. When you create a JSPDynPage with NWDS it always puts in the jspnative line. To resolve it I removed the line
<property name="ComponentType" value="jspnative"/>
from the portal-app.xml file.
Add a comment