You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hisameer <co...@yahoo.com> on 2009/10/06 03:20:36 UTC

Struts 2 runtime variable names

hello everyone,

I need to change the s:select name parameter's value depending on the index
of the list.

I have the following code :

<%! int i=1; %>
   <s:if test="#session.coverageLimitList.size>0">
	<s:iterator value="#session.coverageLimitList" status="index_count">

	<tr height="22">
         <td width="30%" class="contentheadertext1"
align="right"><s:property value="cvgDescription" />
         </td>
	<td width="30%" class="contentheadertext1" align="center"><%= i %><s:select  
name="%     
              {'form.cvgcode'+i}" onchange="this.form.submit()"
headerKey="0" headerValue="Please Select" 
              required="true" list="cvgCode"  cssStyle="width:150px" /></td>
        <td width="40%" class="contentheadertext1" align="center"><s:select
name="%{'form.cvglimit'+i}" 
            onchange="this.form.submit()" headerKey="0" headerValue="Please
Select" required="true" 
            list="cvglimit"  cssStyle="width:150px" /></td>

         <% i++; %>
	</tr>
       </s:iterator>
    </s:if>

All I want is if the list is in the first level the name should be
form.cvgcode1 and so on. I tried using declaring a variable i and
incrementing it everytime but its not working. The value always being set is
form.cvgcodenull. Please advise me what should I do?
-- 
View this message in context: http://www.nabble.com/Struts-2-runtime-variable-names-tp25761232p25761232.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts 2 runtime variable names

Posted by Tommy Pham <to...@yahoo.com>.


________________________________
From: Alex Siman <al...@gmail.com>
To: user@struts.apache.org
Sent: Mon, October 5, 2009 8:10:53 PM
Subject: Re: Struts 2 runtime variable names


I use such approach:

<s:iterator value="#session.coverageLimitList" status="index_count">
    <s:set var="i" value="#index_count.count"/>
    ...
    "%{'form.cvgcode' + #i}"
    ...
    "%{'form.cvglimit' + #i}"
    ...
</s:iterator>


hisameer wrote:
> 
> hello everyone,
> 
> I need to change the s:select name parameter's value depending on the
> index of the list.
> 
> I have the following code :
> 
> <%! int i=1; %>
>    <s:if test="#session.coverageLimitList.size>0">
>     <s:iterator value="#session.coverageLimitList" status="index_count">
> 
>     <tr height="22">
>          <td width="30%" class="contentheadertext1"
> align="right"><s:property value="cvgDescription" />
>          </td>
>     <td width="30%" class="contentheadertext1" align="center"><%= i
> %><s:select   name="%    
>               {'form.cvgcode'+i}" onchange="this.form.submit()"

try {'form.cvgcode'+#index_count.count} and you don't have to declare and increment i.

> headerKey="0" headerValue="Please Select" 
>               required="true" list="cvgCode"  cssStyle="width:150px"
> /></td>
>         <td width="40%" class="contentheadertext1"
> align="center"><s:select name="%{'form.cvglimit'+i}" 

{'form.cvglimit'+#index_count.count}

http://struts.apache.org/2.1.8/docs/iterator.html

>             onchange="this.form.submit()" headerKey="0"
> headerValue="Please Select" required="true" 
>             list="cvglimit"  cssStyle="width:150px" /></td>
> 
>          <% i++; %>
>     </tr>
>        </s:iterator>
>     </s:if>
> 
> All I want is if the list is in the first level the name should be
> form.cvgcode1 and so on. I tried using declaring a variable i and
> incrementing it everytime but its not working. The value always being set
> is form.cvgcodenull. Please advise me what should I do?
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-runtime-variable-names-tp25761232p25762277.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Re: Struts 2 runtime variable names

Posted by hisameer <co...@yahoo.com>.
Hi Alex,

Thank you very much for your help=). It worked like a charm. I tried using
s:set but forgot to put .count at the end of the index_count. But thanks for
figuring this out.

-Sameer



Alex Siman wrote:
> 
> I use such approach:
> 
> <s:iterator value="#session.coverageLimitList" status="index_count">
>     <s:set var="i" value="#index_count.count"/>
>     ...
>     "%{'form.cvgcode' + #i}"
>     ...
>     "%{'form.cvglimit' + #i}"
>     ...
> </s:iterator>
> 
> 
> hisameer wrote:
>> 
>> hello everyone,
>> 
>> I need to change the s:select name parameter's value depending on the
>> index of the list.
>> 
>> I have the following code :
>> 
>> <%! int i=1; %>
>>    <s:if test="#session.coverageLimitList.size>0">
>> 	<s:iterator value="#session.coverageLimitList" status="index_count">
>> 
>> 	<tr height="22">
>>          <td width="30%" class="contentheadertext1"
>> align="right"><s:property value="cvgDescription" />
>>          </td>
>> 	<td width="30%" class="contentheadertext1" align="center"><%= i
>> %><s:select   name="%     
>>               {'form.cvgcode'+i}" onchange="this.form.submit()"
>> headerKey="0" headerValue="Please Select" 
>>               required="true" list="cvgCode"  cssStyle="width:150px"
>> /></td>
>>         <td width="40%" class="contentheadertext1"
>> align="center"><s:select name="%{'form.cvglimit'+i}" 
>>             onchange="this.form.submit()" headerKey="0"
>> headerValue="Please Select" required="true" 
>>             list="cvglimit"  cssStyle="width:150px" /></td>
>> 
>>          <% i++; %>
>> 	</tr>
>>        </s:iterator>
>>     </s:if>
>> 
>> All I want is if the list is in the first level the name should be
>> form.cvgcode1 and so on. I tried using declaring a variable i and
>> incrementing it everytime but its not working. The value always being set
>> is form.cvgcodenull. Please advise me what should I do?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-runtime-variable-names-tp25761232p25762545.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts 2 runtime variable names

Posted by Alex Siman <al...@gmail.com>.
I use such approach:

<s:iterator value="#session.coverageLimitList" status="index_count">
    <s:set var="i" value="#index_count.count"/>
    ...
    "%{'form.cvgcode' + #i}"
    ...
    "%{'form.cvglimit' + #i}"
    ...
</s:iterator>


hisameer wrote:
> 
> hello everyone,
> 
> I need to change the s:select name parameter's value depending on the
> index of the list.
> 
> I have the following code :
> 
> <%! int i=1; %>
>    <s:if test="#session.coverageLimitList.size>0">
> 	<s:iterator value="#session.coverageLimitList" status="index_count">
> 
> 	<tr height="22">
>          <td width="30%" class="contentheadertext1"
> align="right"><s:property value="cvgDescription" />
>          </td>
> 	<td width="30%" class="contentheadertext1" align="center"><%= i
> %><s:select   name="%     
>               {'form.cvgcode'+i}" onchange="this.form.submit()"
> headerKey="0" headerValue="Please Select" 
>               required="true" list="cvgCode"  cssStyle="width:150px"
> /></td>
>         <td width="40%" class="contentheadertext1"
> align="center"><s:select name="%{'form.cvglimit'+i}" 
>             onchange="this.form.submit()" headerKey="0"
> headerValue="Please Select" required="true" 
>             list="cvglimit"  cssStyle="width:150px" /></td>
> 
>          <% i++; %>
> 	</tr>
>        </s:iterator>
>     </s:if>
> 
> All I want is if the list is in the first level the name should be
> form.cvgcode1 and so on. I tried using declaring a variable i and
> incrementing it everytime but its not working. The value always being set
> is form.cvgcodenull. Please advise me what should I do?
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-runtime-variable-names-tp25761232p25762277.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts 2 runtime variable names

Posted by Alex Siman <al...@gmail.com>.
I use such approach:


    
    ...
    "%{'form.cvgcode' + #i}"
    ...
    "%{'form.cvglimit' + #i}"
    ...



hisameer wrote:
> 
> hello everyone,
> 
> I need to change the s:select name parameter's value depending on the
> index of the list.
> 
> I have the following code :
> 
> <%! int i=1; %>
>    0">
> 	
> 
> 	

>          	
>          
> 		<%= i %> name="%     
>               {'form.cvgcode'+i}" onchange="this.form.submit()"
> headerKey="0" headerValue="Please Select" 
>               required="true" list="cvgCode"  cssStyle="width:150px" />
>         	name="%{'form.cvglimit'+i}" 
>             onchange="this.form.submit()" headerKey="0"
> headerValue="Please Select" required="true" 
>             list="cvglimit"  cssStyle="width:150px" />
> 
>          <% i++; %>
> 	
>        
>     
> 
> All I want is if the list is in the first level the name should be
> form.cvgcode1 and so on. I tried using declaring a variable i and
> incrementing it everytime but its not working. The value always being set
> is form.cvgcodenull. Please advise me what should I do?
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-runtime-variable-names-tp25761232p25762245.html
Sent from the Struts - User mailing list archive at Nabble.com.