More questions about the following:

1) It says in logic tags reference:
id: "The name of a page scope JSP bean that will
contain the current element of the collection on each
iteration, if it is not null."

So, it means myList ArrayList should conform
to JavaBean routines, is that right? For example:

If I have a List4Js class, it has to have
getters/seters
for getting/setting ArrayLists:

ArrayList myList = List4J.getResultList();

And the elements of an ArrayList should be a bean too.

2) If I want to get a collection of arraylists, I can
use the <logic:iterate> tag as following:

 <logic:iterate id="jsList" name="listForJavaScript"
             indexId="idx">
    <logic:iterate id="myBean" name="jsList"
             indexId="index">
        jsArray[<%=idx%>][<%=index%>] = 
             <%=myBean.getYourValue()%>;
    </logic:iterate>    
</logic:iterate>                
 
Since JavaScript Array usually has the following form:
  myArray = new Array("sample", 1);

Do I need to conform to the above routine to create an

JavaScript Array element in order to correctly display
the results?

regards,

rick






--- James Childers <[EMAIL PROTECTED]> wrote:
> You'll need to do a couple of things:
> 
> 1) (Assuming you're using Struts, of course.) Create
> your Java array/collection/whatever in the Action
> that gets hit before your JSP page:
>       List myList = new ArrayList();
>       // populate the list, la la la
>       request.addAttribute("listForJavascript", myList);
>       return mapping.findForward("success");  // Takes
> you to, say, bongabonga.jsp
> 
> 2) In bongabonga.jsp:
>       <head>
>       <script type="text/javascript">
>               var jsArray = new Array();              // Do you have to init
> this? I don't remember.
>               <logic:iterate id="jsList"
> name="listForJavaScript" indexId="idx">
>                       jsArray[<%=idx%>] = <%=jsList.getYourValue()%>;
>               </logic:iterate>                
>       </script>
>       
> 3) Debug. This is all from memory. I'm sure there
> are some glaring errors here, but this is the
> general flow.
> 
> -= J
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to