on 01-15-2005 1:02 AM
Hi,
I have one JSPDynpage and two JSPs. The first JSPs is a form that takes in a number of values. Upon clicking the button in the form, I have a bean that sets these form values in the doProcessAfterInput method. I have system.out.println's in a number of places and can see that these values are being set. However in the 2nd JSP, when I use the bean methods to get the values, they are all null. I've tried storing the beans in the portal's Context, Session and Profile. Why doesn't the 2nd JSP have access to the correct scope of the bean???
JSPDynpage code:
package com.waveset.spml.password;
import com.waveset.spml.password.idmSpmlBean;
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 ChangePassword extends PageProcessorComponent {
public DynPage getPage() {
return new ChangePasswordDynPage();
}
public static class ChangePasswordDynPage extends JSPDynPage {
private final static int INITIAL_STATE = 0;
private final static int CHANGE_PASS_STATE = 1;
private int state = INITIAL_STATE;
private String idm_url = null;
private String idm_uid = null;
private String old_password = null;
private String new_password = null;
private String confirm_new_password = null;
private idmSpmlBean idmSpmlBean = null;
public ChangePasswordDynPage() {
}
public void doInitialization() {
System.out.println("In doInitialization()");
IPortalComponentRequest request =
(IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
IPortalComponentSession componentSession =
request.getComponentSession();
Object o = componentSession.getValue("idmSpmlBean");
if (o == null || !(o instanceof idmSpmlBean)) {
idmSpmlBean = new idmSpmlBean();
componentSession.putValue("idmSpmlBean", idmSpmlBean);
myContext.putValue("idmSpmlBean", idmSpmlBean);
componentSession.putValue("idmSpmlBean", idmSpmlBean);
} else {
idmSpmlBean = (idmSpmlBean) o;
}
state = INITIAL_STATE;
}
public void ButtonClicked(Event event) throws PageException {
System.out.println("In ButtonClicked() ");
state = CHANGE_PASS_STATE;
System.out.println(
"onButtonClicked changed state to CHANGE_PASS_STATE");
}
public void doProcessAfterInput() throws PageException {
System.out.println("In doProcessAfterInput");
IPortalComponentRequest request =
(IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
IPortalComponentSession componentSession =
request.getComponentSession();
//idmSpmlBean myBean = (idmSpmlBean) myContext.getValue("idmSpmlBean");
idmSpmlBean myBean =
(idmSpmlBean) componentSession.getValue("idmSpmlBean");
InputField idm_url_input =
(InputField) getComponentByName("idm_url_input");
if (idm_url_input != null) {
this.idm_url = idm_url_input.getValueAsDataType().toString();
myBean.setIdmUrl(idm_url);
}
InputField idm_uid_input =
(InputField) getComponentByName("idm_uid_input");
if (idm_uid_input != null) {
this.idm_uid = idm_uid_input.getValueAsDataType().toString();
myBean.setIdmUid(idm_uid);
}
InputField new_password_input =
(InputField) getComponentByName("new_password_input");
if (new_password_input != null) {
this.new_password =
idm_uid_input.getValueAsDataType().toString();
myBean.setNewPassword(new_password);
}
InputField old_password_input =
(InputField) getComponentByName("old_password_input");
if (old_password_input != null) {
this.old_password =
old_password_input.getValueAsDataType().toString();
myBean.setOldPassword(old_password);
}
InputField confirm_new_password_input =
(InputField) getComponentByName("confirm_new_password");
if (confirm_new_password_input != null) {
this.confirm_new_password =
confirm_new_password_input.getValueAsDataType().toString();
myBean.setConfirmNewPassword(confirm_new_password);
}
}
public void doProcessBeforeOutput() throws PageException {
System.out.println("In doProcessBeforeOutput()");
if (state == INITIAL_STATE) {
this.setJspName("changePassword.jsp");
} else {
this.setJspName("passwordChange.jsp");
}
}
}
}
The first JSP is just a form, but here is the 2nd JSP:
<%@ page language="java" %>
<%@ taglib uri= "tagLib" prefix="hbj" %>
<jsp:useBean id="idmspmlBean" scope="session" class="com.waveset.spml.password.idmSpmlBean" />
<hbj:content id="myContext2" >
<hbj:page title="PageTitle2">
<hbj:form id="myFormId2" >
<hbj:textView
id="message1"
design="HEADER1" >
<% message1.setText("uid = " + idmspmlBean.getIdmUid());
%>
</hbj:textView>
<p>
<p>
<hbj:textView
id="message2"
design="HEADER1" >
<% message2.setText("url = " + idmspmlBean.getIdmUrl());
%>
</hbj:textView>
<p>
<p>
<hbj:textView
id="message3"
design="HEADER1" >
<% message3.setText("old password = " + idmspmlBean.getOldPassword());
%>
</hbj:textView>
<p>
<p>
<hbj:textView
id="message4"
design="HEADER1" >
<% message4.setText("New Password = " + idmspmlBean.getNewPassword());
%>
</hbj:textView>
<p>
<p>
</hbj:form>
</hbj:page>
</hbj:content>
All of these values print out null.
My setMethods are setting the correct value, however my get methods are always returning null.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my portalapp.xml, I set
<component-profile>
<property name="com.sap.portal.reserved.iview.IsolationMode" value="URL">
And that didn't work. I am testing the JSP/Bean communication with the UserNameBean example from the PDK. If I cannot get even the sample to work, how is one to do any real development on EP6?
Hi Marty,
Here is my portalapp.xml file:
<?xml version="1.0" encoding="utf-8"?>
<application>
<application-config>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
<property name="SharingReference" value="htmlb"/>
</application-config>
<components>
<component name="DynPageOne">
<component-config>
<property name="ClassName" value="com.mycompany.basicexample.DynPageOne"/>
<property name="SecurityZone" value="com.mycompany.basicexample.DynPageOne/low_safety"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
<property name="com.sap.portal.reserved.iview.IsolationMode" value="URL"/>
</component-profile>
</component>
</components>
<services/>
</application>
I also created a getter method in my bean to return a static value and that value is returned correctly. Any more ideas?
I noticed that when you call the get the bean's context from the Java class, you use:
idmSpmlBean myBean =
(idmSpmlBean) componentSession.getValue("idmSpmlBean");
Yet, when calling from the 2nd JSP you are giving it an ID=idmspmlBean.
jsp:useBean id="idmspmlBean" scope="session" class="com.waveset.spml.password.idmSpmlBean" />
Not 100% positive, but I think the class and the JSP need to be using the same IDs. In the class you used a capital Spml, the JSP you used a lowercase spml.
Hope this helps,
Marty
Yes, I have tried with scope=application and session.
I have the same problem as when I try it with the BasicExample in the JSPDynpage sample from the PDK.
Problem is similar to this thread:
System.out.println()'s indicate the values are being set, however when they're read in to the JSP, they are NULL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vu,
did u change the scope to "application" instead of "session" in <jsp:useBean id="idmspmlBean" scope="session" >. As well put system.out.println statements in bean also. Check the values while setting the bean values and while calling the bean values. Check whether null values are not stored in the bean.
Thanks,
Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vu,
Many of us have answered your issues and if you think that your problem is solved, you are supposed to give points to the members. Till now you havent assigned any points. Remember to do this by clicking on the yellow star.
Coming to your issue, Trying printing your values to console using system.out.println after clicking on submit button. Check the values whether you can get them in program. As well in <jsp:useBean id="idmspmlBean" scope="session" class="com.waveset.spml.password.idmSpmlBean" />
change the scope from "session" to "application" and check.
Regards,
Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Thanks for the tip, I wasn't sure how to give points before. I have System.out.println()'s in several places and I have checked what the values of these variables are once I have clicked the buttons. The values are correct. It's when I get to the 2nd JSP the values are null. Any other tips?
-Vu
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.