on 02-01-2006 10:33 AM
I want create a easy par (Portal Application Project) witch do somethink in the servlet transfer data with a bean to the jsp.
If i call this site the .jsp crate a new instance of bean but don't find the bean of the servlet!
How can help me? I search more as two days for solution ;-((
See this:
-
(myservlet.java)
package com.firma.test
import com.firma.test.mybean
import ...
public class displayJSP extends PageProcessorComponent {
public DynPage getPage(){
return new siteDynPage();
}
public static class siteDynPage extends JSPDynPage{
public void doInitialization(){
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
mybean myBean = new mybean();
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
((IPortalComponentRequest)getRequest()).getNode().putValue("myBean", myBean);
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
myBean.setMyText("TEST_OUTPUT1");
// Ausgabe
this.setJspName("myjsp.jsp");
}
}
}
-
(myjsp.jsp)
<BR>
<jsp:useBean
id="myBean"
scope="application"
class="com.firma.test.mybean"
/>
VAL: <jsp:getProperty name="myBean" property="myText" />
<BR>
-
(mybean.java)
package com.firma.test
import ...
import java.io.Serializable;
public class mybean implements Serializable {
private String myText = "LEER!!!";
public String getMyText() {
return myText;
}
public void setMyText(String string) {
myText = string;
}
}
Hi Patrick,
first, welcome on SDN!
About your question: The most common problem is when you created your project via NWDS wizards and the wizard put two lines within the portalapp.xml, which are wrong. These are:
<property name="ComponentType" value="jspnative"/> <property name="JSP" value="...some JSP name ..."/>
Just delete them from your portalapp.xml.
Hope it helps
Detlev
PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Detlev,
the NWDS added realy these two lines i deleted, but the problem is the same as before (nearly).
And I added these lines 4testing:
- - - - - - - - - - - - - - - - - -
<BR>
GET: <jsp:getProperty name="myBean" property="myText" />
<BR>
SET: <jsp:setProperty name="myBean" property="myText" value="TESTING !!! JSP" />
<BR>
GET: <jsp:getProperty name="myBean" property="myText" />
<BR>
- - - - - - - - - - - - - - - - - -
1st. GET is empty, 2nd. GET is "TESTING !!! JSP".
I think the JSP creates a new bean, whats wrong with these line
- - - - - - - - - - - - - - - - - -
(portalapp.xml)
<component name="displayJSP">
<component-config>
<property name="ClassName" value="com.firma.test.displayJSP"/>
<property name="SecurityZone" value="com.firma.test/high_safety"/>
<property name="ComponentType" value="jspnative" />
<property name="JSP" value="pagelet/sitemap.jsp" />
</component-config>
- - - - - - - - - - - - - - - - - -
If i delete the 2 lines in portalapp.xml i resolved a error of the Server.
Message was edited by: Patrick Schreck
Hi Patrick,
you put the bean into the ServletRequest, so changing the scope maybe to "request" could make it work.
Also check out http://help.sap.com/saphelp_nw04/helpdata/en/2e/c87f41849d030de10000000a1550b0/frameset.htm and around.
Hope it helps
Detlev
Thanks,
scope i changed every time in JSP and in the servlet i write:
request.getServletRequest().setAttribute("myBean", myBean);
request.getNode().putValue("myBean", myBean);
request.getServletRequest().setAttribute("myBean", myBean);
- - - - - - - - - - - - - - - - - -
portalapp.xml ??? There is all corectly??
If i delete the two lines i have an error.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.