How to pass parameters to s:component inside s:iterator?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass parameters to s:component inside s:iterator?

albert kao-2
How to pass parameters to s:component inside s:iterator?
e.g. These simpilied codes pass the parameter "John" to items.jsp.
However, the browser displays an empty string.

<s:iterator begin="0" end="%{client.size - 1}" value="client"
status="status">
  <s:component template="items.jsp" theme="custom"
name="%{'client['+#status.index+'].firstName'}" label="firstName.label">
    <s:if test="#status.index == 1">
      <s:param name="inputValue" value="'John'"/>
    </s:if>
  </s:component>
</s:iterator>


items.jsp:
<s:textfield
  name="%{#fieldname}"
  value="%{parameters.inputValue}"/>
/>
Reply | Threaded
Open this post in threaded view
|

RE: How to pass parameters to s:component inside s:iterator?

Yasser Zamani-2
Hi Albert,

Could you try without the inner s:if tag? I remember that some tags don't work inside each other :(

Despite if it was the problem or not, I think it's more readable design to move iterator and if tags inside the component (items.jsp) itself, have you ever considered it?

Regards.

>-----Original Message-----
>From: albert kao <[hidden email]>
>Sent: Saturday, October 5, 2019 7:26 PM
>To: Struts Users Mailing List <[hidden email]>
>Subject: How to pass parameters to s:component inside s:iterator?
>
>How to pass parameters to s:component inside s:iterator?
>e.g. These simpilied codes pass the parameter "John" to items.jsp.
>However, the browser displays an empty string.
>
><s:iterator begin="0" end="%{client.size - 1}" value="client"
>status="status">
>  <s:component template="items.jsp" theme="custom"
>name="%{'client['+#status.index+'].firstName'}" label="firstName.label">
>    <s:if test="#status.index == 1">
>      <s:param name="inputValue" value="'John'"/>
>    </s:if>
>  </s:component>
></s:iterator>
>
>
>items.jsp:
><s:textfield
>  name="%{#fieldname}"
>  value="%{parameters.inputValue}"/>
>/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]