On Fri, 8 Mar 2002, Matt Read wrote:
> Date: Fri, 8 Mar 2002 20:52:18 -0000
> From: Matt Read <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: <html:hidden> - property tag required?
>
> Could anyone explain why the property tag on <html:hidden> (and all tags
> that subclass BaseFieldTag) is required (according to struts-html.tld)? I'm
> trying to do the following:
>
> <bean:parameter id="gid" name="gid" />
> <html:form action="/myaction">
> <html:hidden name="gid" />
> </html:form>
>
The "property" attribute defines the name of the input field that will be
sent along when the form is submitted (i.e. it ends up in the "name"
attribute of the generated <input> element). It is named "property" here
(and on all the other HTML tags) for consistency with the way that
property names are referenced in the bean and logic tag libraries.
> This should explain the problem, but to elaborate, I want to include a
> hidden value in my form that comes from a bean other than the ActionForm
> bean for the form, i.e. from the parameter itself.
>
> If I change struts-html.told to required=false then the above code writes
> this:
> <input type="hidden" name="null" value="1">
>
> If I change the above code to:
> <html:hidden name="gid" property="gid" />
>
> Then I get an error saying that there's no getGid() property on my gid
> bean... which is correct. But the general trend seems to be that property is
> optional where the bean can be evaluated as a String.
>
> Am I misunderstanding something?
>
You can use a runtime expression to accomplish what you're after:
<html:form action="/myaction">
<html:hidden property="gid"
value='<%= request.getParameter("gid") %>'/>
</html:form>
> Matt.
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>