You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yaroslav Novytskyy <sp...@n-ix.com.ua> on 2005/05/25 12:01:57 UTC

use action-form's properties in JSTL

Hello!

How can I get a form's property in JSP to use it in EL in JSTL tags.

e.g.
<html:form action="/myAction">
	<html:hidden property="elementIndex"/>
</html:form>

<c:set var="elementIndex" value="??????????????"/>	<- define here

<c:if test="${!empty myBean.list[elementIndex]}">	<- use here
	<somethig>
</c:if>


Yaroslav Novytskyy

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


Re: use action-form's properties in JSTL

Posted by atta-ur rehman <at...@gmail.com>.
Hi,

try 

formName.property

formName is the name that you defined in your struts.xml for the form
of current action. it should work. and the reason it works that Struts
puts the form object under the 'name' key in either request and
session scope depending upon the 'scope' attribute of your current
action.

Now JSTL shouldn't have a problem finding a bean in either request or
session scope as long as you know it's name.

hope this helps.

ATTA


On 5/25/05, Yaroslav Novytskyy <sp...@n-ix.com.ua> wrote:
> Hello!
> 
> How can I get a form's property in JSP to use it in EL in JSTL tags.
> 
> e.g.
> <html:form action="/myAction">
>         <html:hidden property="elementIndex"/>
> </html:form>
> 
> <c:set var="elementIndex" value="??????????????"/>      <- define here
> 
> <c:if test="${!empty myBean.list[elementIndex]}">       <- use here
>         <somethig>
> </c:if>
> 
> 
> Yaroslav Novytskyy
> 
> ---------------------------------------------------------------------
> 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


Re: use action-form's properties in JSTL

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Yaroslav Novytskyy" <sp...@n-ix.com.ua>
>
> How can I get a form's property in JSP to use it in EL in JSTL tags.

> <html:form action="/myAction">
> <html:hidden property="elementIndex"/>
> </html:form>
>
> <c:set var="elementIndex" value="??????????????"/> <- define here
>
> <c:if test="${!empty myBean.list[elementIndex]}"> <- use here
> <somethig>
> </c:if>

If you're going to use JSTL, you'll probably want to switch to the Struts-EL
tags so you can use expressions with them as well.

The form is a bean, so you can just use the name you configured in
struts-config.xml.
     <c:out value="${someForm.elementIndex}"/>

You don't really need the <c:set> in your example above, just use the form
element directly:
     <c:if test="${!empty myBean.list[someForm.elementIndex]}">
but it will work either way.

If you're using a dynamic form, you'll need to go through the map to get at
the properties.

-- 
Wendy Smoak



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