RE: Action BEFORE a page is constructed?

2001-07-10 Thread Moons Manuel

action path=/prepareorder type=sandwich.web.order.PrepareOrderAction
forward  name=success path=/order.jsp/
/action

If you want to do some preparations before you create the form  you can make
a new actionclass without a form class.

action path=/prepareorder type=sandwich.web.order.PrepareOrderAction
forward  name=success path=/order.jsp/
/action

Now when you want to call you new screen you first call this action wich is
not linked to a form, when this action succeeds, you can call you jsp page,
wich has a form in it.  To fill this form you make an instance of this forms
form class and fill it using the set methods.  After this you put this form
into the session scope.  Like this
request.getSession().setAttribute(orderForm,orderForm);

Now you form will be filled in when it is shown on the screen.

 -Original Message-
 From: peter [SMTP:[EMAIL PROTECTED]]
 Sent: dinsdag 10 juli 2001 8:50
 To:   [EMAIL PROTECTED]
 Subject:  Action BEFORE a page is constructed?
 
 Action BEFORE a page is constructed?
 
 As far as I understood the working of struts, you inherit the FORM and
 the ACTION classes. The forms are constructed BEFORE a page is shown -
 if values
 are already available, they will be shown. AFTER the page is submitted,
 the
 ACTION is called with the FORM element filled with the appropriate
 values.
 
 But what do I do to make any data available to the next page?
 
 I can do so in the preceeding ACTION. But this means, I have to do so in
 all
 preceding actions of this page. This would be a copy of code.
 So I am simply looking for a way to be called, just BEFORE the page is
 created.
 The only mehtod I know, is the Construction of the FORM. But there I do
 not have any link to the SessionContext which is my main anker element.
 
 If anyone has an idea what I am talking about, please help.
 
 Thanks
 Peter
 
 [EMAIL PROTECTED]
 
 



iterate problem

2001-07-09 Thread Moons Manuel

Hello everyone.

I am currently having some problems with iterating over an array of objects.

In my action class I have put an array into the session object
(request.getSession().setAttribute(orderedsandwiches,...);)

I would like to loop over these objects in my jsp page.

I am trying to do this like this:

bean:define id=orderedsandwiches name=orderedsandwiches/

table
logic:iterate id=element name=orderedsandwiches
tr
td
bean:write name=element property=name/
/td
/tr
/logic:iterate
/table


But when I try to do this, I get an exception like the following:

9-jul-01 14:21:07 GMT+02:00 Error HTTP
[WebAppServletContext(5325170,sandwich)] Root cause of ServletException
javax.servlet.jsp.JspException: Cannot find bean element in scope null
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:493)
at
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:179)
at jsp_servlet._viewall._jspService(_viewall.java:183)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImp
l.java:157)
at
org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.ja
va:1683)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1520)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:485)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:12
65)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1622)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)



When I loop through the array using jsp snippets, I can print out the
contents of the array like this:


table
%
  OrderBean []ob = (OrderBean[])orderedsandwiches;
  for(int i=0;iob.length;i++) {
%trtd%
out.println(ob[i]);
%tdtr%
  }
%
/table

The strange thing about all of this is that in another jsp page, I do almost
the same thing and there this works without any problems.

Does anyone have an idea to solve this problem