struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: Question about logic:iterator, indexId and hidden fields
Date Tue, 06 Apr 2004 19:52:29 GMT
I just thought up one solution that depends on having a dummy field in 
your beans, the collection of which you are iterating over.

<nested:iterate property="beans" id="currentBean">
   <c:set target="currentBean" property="dummy" value="indexId"/>
   <html:hidden name="dummy"/>
</nested:iterate>



Adam

Light the touch paper & stand clear - it might blow up in your face!


On 04/06/2004 08:45 PM Eric Hodges wrote:
> I have both cases.  Some of my forms are outside the iterator, others
> inside.  The common factor is that each iteration produces its own
> <nested:submit> tag.  I have lists of things.  Each thing has a button that
> lets the user edit that particular thing.
> 
> Am I missing an obvious pattern here?  Surely lots of struts web apps do
> this sort of thing.
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
> Sent: Tuesday, April 06, 2004 9:58 AM
> To: Struts Users Mailing List
> Subject: Re: Question about logic:iterator, indexId and hidden fields
> 
> 
> Actually you might need a name attribute on that hidden field as well 
> ... which could get complicated. It depends on where you form is. Inside 
> or outside the logic:iterate?
> 
> On 04/06/2004 06:43 PM Adam Hardy wrote:
> 
>>This is pseudo-code, so before use it'll need corrections! For JSP2 & JSTL
>>
>><logic:iterate index="indexId">
>>  <input type="hidden" value="<c:out var="indexId"/>"/>
>>
>>
>>
>>On 04/06/2004 06:30 PM Eric Hodges wrote:
>>
>>
>>>Does anyone know of a simple way to send a logic:iterate's indexId 
>>>back as a
>>>form bean property on submit?
>>>
>>>
>>>-----Original Message-----
>>>From: Eric Hodges Sent: Friday, April 02, 2004 7:24 AM
>>>To: Struts Users Mailing List
>>>Subject: RE: Question about logic:iterator, indexId and hidden fields
>>>
>>>
>>>I mean when the page is compiled, the <nested:submit> tag is converted 
>>>to an
>>><input> tag before the <%=index%> tag produces Java code.
>>>
>>>I think the taglib directive *is* incorrect whenever I get the <%=index%>
>>>tag to produce Java code, that's why it leaves <nested:submit> in the 
>>>HTML
>>>output.  When I remove the <%=index%> tag, or when I include it in such
a
>>>way that it doesn't generate Java code, the <nested:submit> tag is
>>>recognized.
>>>
>>>What I want to do is write a <nested:submit> tag that passes the value of
>>>Integer "index" to a Javascript function in its "onClick" function.
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: Karr, David [mailto:David.Karr@wamu.net]
>>>Sent: Thursday, April 01, 2004 8:02 AM
>>>To: Struts Users Mailing List
>>>Subject: RE: Question about logic:iterator, indexId and hidden fields
>>>
>>>
>>>I think we're having trouble understanding what you're doing.  In
>>>particular, you say that "the <nested:submit> tag is evaluated before
>>>the <%=index%> tag".  What do you mean by that?  Then, you are now
>>>saying that after fixing your scriptlet expression reference, you say
>>>that the "<nested:submit> tag isn't replaced with an <input> tag".
 Do
>>>you mean that in the HTML output, you see "<nested:submit ..>" instead
>>>of "<input ...>"?  If you're really seeing "<nested:submit ...>" in
the
>>>HTML output, then this would indicate that your taglib directive is
>>>incorrect or not present.
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Eric Hodges [mailto:EHodges@USDataworks.com] Sent: Thursday, 
>>>>April 01, 2004 6:30 AM
>>>>To: user@struts.apache.org
>>>>Subject: RE: Question about logic:iterator, indexId and hidden fields
>>>>
>>>>
>>>>Thanks for the suggestion, but that doesn't work either.  The
>>>><nested:submit> tag isn't replaced with an <input> tag when I
use the 
>>>>syntax
>>>>you suggest.  I've tried many variations on these syntaxes.  If the JSP
>>>>expression get's parsed, the struts tags aren't understood.  If the 
>>>>struts
>>>>tags are understood the JSP expression isn't parsed.
>>>>
>>>>Any other ideas?  Surely this is a common usage pattern.
>>>>
>>>>-----Original Message-----
>>>>From: Martin Cooper [mailto:martinc@apache.org]
>>>>Sent: Wednesday, March 31, 2004 10:46 AM
>>>>To: user@struts.apache.org
>>>>Subject: Re: Question about logic:iterator, indexId and hidden fields
>>>>
>>>>
>>>>
>>>>"Eric Hodges" <EHodges@USDataworks.com> wrote in message
>>>>news:26439701CF1FE441B8EC1A2ADC7E87EE17843A@neptune.usdataworks.com...
>>>>
>>>>
>>>>>I have a form with a list of elements on it.  Each element 
>>>>
>>>>
>>>>has an "Edit"
>>>>
>>>>
>>>>>button associated with it.  When the user clicks the Edit 
>>>>
>>>>
>>>>button for a
>>>>
>>>>
>>>>>specific element, I want to send back the value of indexId 
>>>>
>>>>
>>>>in a hidden
>>>>field
>>>>
>>>>
>>>>>on the form.  I can't figure out a clean way to do this.  The
>>>>
>>>>
>>>>documentation
>>>>
>>>>
>>>>>says "indexId" will create a bean, but it really creates an 
>>>>
>>>>
>>>>Integer (which
>>>>
>>>>
>>>>>isn't a JavaBean).  I've tried passing my indexId to a 
>>>>
>>>>
>>>>Javascript function
>>>>
>>>>
>>>>>that sets the form's hidden field sort of like this:
>>>>>
>>>>><nested:submit propert="edit" value="Edit"
>>>>>onclick="setEditIndex(<%=index%>)"/>
>>>>>
>>>>>but the <nested:submit> tag is evaluated before the <%=index%>
tag
>>>>
>>>>
>>>>The problem is that you have illegal JSP syntax for the 'onclick' 
>>>>attribute.
>>>>The attribute value must be a string literal or a scripting 
>>>>expression. You
>>>>cannot mix the two. Try this instead:
>>>>
>>>> onclick='<%= "setEditIndex(" + index + ")" %>'
>>>>
>>>>-- 
>>>>Martin Cooper
>>>>
>>>>
>>>>
>>>>
>>>>>Right now I've got some ugly JSP code that outputs the 
>>>>
>>>>
>>>>submit element that
>>>>
>>>>
>>>>>calls the Javascript function that sets the hidden field.  
>>>>
>>>>
>>>>There must be a
>>>>
>>>>
>>>>>simpler way.  Any ideas?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
> 
> 


-- 
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message