I think I found couple of problems, the biggest of which being not including
the <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> in the
beginning. I literally slept on it to figure out. Do I feel silly. However,
there are also few more problems due to nested bean in the form bean and
casting Hashtable entry to a Unit, which seems to be the only remaining
problem since I am now able to iterate and print Unit's "toString()". I'll
post a postmortem once I solve this last piece.
Thanks,
--a

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


Ali,

Sorry I think I gave you a red herring.

Units is a property of a report bean?

Then try

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

assuming that reportForm has a getReport() method and
Report has a getUnits() method.

Failing that try adding just a simple test String
property to the form and see if you can output using
bean:write.

PS Even if you don't need it Report will need a
public setUnits(Hashtable input)
{
...
}

to conform to the bean standard. I normally just write
the method signature with empty braces.


--- Ali Ozoren <[EMAIL PROTECTED]> wrote:
> 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
>
>
>
>
>
>
>
>


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.
http://im.yahoo.com

Reply via email to