We all strive for separation and low-coupling of everything these days, and rightly so, and to me that also means the ability to change frameworks without touching my presentation layer (within some necessary constraints of course)
You make perfectly valid points though, so throw it all into the hopper and make a decision Kedar! :)
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com
Jim Barrows wrote:
-----Original Message----- From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 2:14 PM To: Struts Users Mailing List Subject: Re: creating a for loop structure for multibox
If I understand correctly, you will get from an Action an upper limit to the number of checkboxes to display, and you want each checkbox to be named 'valueX' where X is the value of the for loop. Some people will argue, but I don't see where a taglib is really required here...
<% // Assume you got a reference to your action form in af, // and that is has a getUpperLimit() method... int ul = af.getUpperLimit(); for (int i = 0; i < ul; i++) { %> <input type="checkbox" name="value<%=i%>"> <% } %>
Not much more than that required. To make them retain state, you'll have to provide some method to determine when a given checkbox is checled, and add a checked attribte accordingly, something like:
<input type="checkbox" name="value<%=i%>" <%=af.getIsChecked(i)=true?"checked":"">
That'll do the trick, assuming getIsChecked() accepts an index value and returns a boolean stating whether that particular checkbox is checked or not.
I have a personal distaste for taglibs in most cases, I know many people disagree, but I figured you might as well know all your options, then you can choose whickever you prefer from an informed position.
And in that spirit:
<struts-html:multibox property="subscriptions" ><struts-bean:write name="_bean" property="code"/></struts-html:multibox> <struts-bean:write name="_bean" property="description"/><br> </struts-logic:iterate> is 4 lines of code plus the 3 lines of code you'll need in reset. Plus the i18n ability with no additional codeing. Not to mention being able to hand off the code to the web design folks and have them easily make things purty.
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com
Jim Barrows wrote:
-----Original Message----- From: Kedar Deshpande [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 1:52 PM To: Struts Users Mailing List Subject: Re: creating a for loop structure for multibox
i am currently using struts tags and cant find a proper
solution. it
would be better to have a simple struts code, otherwise i'll try to use the JSTL.
Then you want the logic:iterate tag.
thank you Kedar
Jim Barrows wrote:
-----Original Message----- From: Kedar Deshpande [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 1:21 PM To: [EMAIL PROTECTED] Subject: creating a for loop structure for multibox
Could someone please post an example of using a 'for loop' structure in
Using JSTL, or Struts tag libs?
a JSP. i need to get the loop limit from the action and
then assign
individual 'value' values for a column of checkboxes so
that i know
which ones were selected and so that they can be set again when viewing the page.
thanks
------------------------------------------------------------
---------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-----------------------------------------------------------
----------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------
---------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]