Adam thanks for the reply. I put my feedback down below:

-----Original Message-----
From: Adam Hardy [mailto:[EMAIL PROTECTED]]
Sent: Saturday, September 22, 2001 5:22 PM
To: [EMAIL PROTECTED]
Subject: Re: Iterating over wrapped form bean's property


Ali,

Try <logic:iterate name="reportForm" property="units"
 id="unit">
   <bean:write name="unit" property="owner"/>

a: did so. I still get "Cannot find bean unit in scope null"

You will also need to populate the form before you use
it. If you enter /jsp/report.jsp as the url the null
error occurs because the reportForm has not been
created yet (although once it has been created it
should work fine because reportForm is sitting in the
session).

a: if it is a new report it will not be populated up front.

If you enter /report.do as the url struts knows that
this is an action, it creates a reportForm for you and
passes it into the perform method of ReportAction.

The perform method then populates the reportForm as
necessary and returns an ActionForward object normally
done by:
return (mapping.findForward("success"));

Now your newly populated form is sitting in the
session ready for your page to use.

a: that is true. i verified this right before the end in the ReportAction as
follows:

      Report r = (Report)request.getSession().getAttribute("rep");
      ReportForm rf =
(ReportForm)request.getSession().getAttribute("reportForm");
      System.out.println("action rf id=" +
String.valueOf(rf.getReport().getId()));
        System.err.println("count=" +
String.valueOf(r.getUnitsAsHashtable().size()));

Just for testing, I put this dummy "rep" variable of type Report into the
session in the login action. Both "rep" and "reportForm" variables are in
session.

Here is another bit of info. I checked the generated servlet code for sample
registration.jsp and my report.jsp

Sample has this snippet:

                /* ----  logic:iterate ---- */
                org.apache.struts.taglib.logic.IterateTag
_jspx_th_logic_iterate_0 = new org.apache.struts.taglib.logic.IterateTag();
                _jspx_th_logic_iterate_0.setPageContext(pageContext);
                _jspx_th_logic_iterate_0.setParent(_jspx_th_logic_equal_5);
                _jspx_th_logic_iterate_0.setId("subscription");
                _jspx_th_logic_iterate_0.setName("user");
                _jspx_th_logic_iterate_0.setProperty("subscriptions");

Whereas mine doesn't, instead it has something like this:
    out.write("\r\n\r\n<logic:iterate scope=\"session\" name=\"rep\"
id=\"aUnit\" type=\"police.Unit\">\r\n  ");

I turned the getter method of units property from

Hashtable getUnits()
to
Unit[] getUnits(), with the necessary changes to return an array, still no
luck. I think I religiously copied the sample registration.jsp and related
files but here I am.

Thanks,
--a








Reply via email to