You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by JOSE L MARTINEZ-AVIAL <jl...@gmail.com> on 2010/12/14 17:26:57 UTC
Calculate module of index in Struts2 iterator
Hello, I'm using Struts2 iterator to setup a list of checkbox in a
table(about 150 checkboxes). I want to have 10 checkbox per row, so I'm
doing the following:
<table>
<tr>
<s:iterator value="securityMasterFields" status="fieldNameStatus"
var="fieldName">
<s:if test="#fieldNameStatus.index % 10 ==0">
</tr><tr>
</s:if>
<td>
<s:checkbox name="fieldsToShow" fieldValue="%{fieldName}"
value="%{fieldName}"/>
</td>
</s:iterator>
</tr>
</table>
It never goes through the if, so I'm assuming the module is not been
calculated correctly. How do I do it?
thanks
Re: Calculate module of index in Struts2 iterator
Posted by Dale Newfield <da...@newfield.org>.
On Dec 24, 2010, at 1:29 PM, JOSE L MARTINEZ-AVIAL <jl...@gmail.com> wrote:
> Thanks for the advice!! I'll follow it.
The best example I forgot to include is when you want to pass in to an attribute a string whose value is the same as the name of one of your action properties.
foo="user" can be confusing, but foo="%{'user'}" and foo="%{user}" are both unambiguous to struts and clear to a human reading the code.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calculate module of index in Struts2 iterator
Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Thanks for the advice!! I'll follow it.
2010/12/24 Dale Newfield <da...@newfield.org>
> On 12/24/10 6:15 AM, JOSE L MARTINEZ-AVIAL wrote:
>
>> <s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
>>
>
> I guess I've not been around on this list much lately (darned work :-/ ).
> So my constant harping about this hasn't been so constant:
>
> I *really* advise people to always use %{} when writing OGNL in a taglib
> attribute. It makes it clear what is to be evaluated as an OGNL expression
> and what's just text. It's not just for readability and maintainability --
> it's also to future-proof your code. In the future struts may be able to
> use more ELs than just OGNL, and its the character out front (% = OGNL; $ =
> EL; # = JUEL (IIRC -- maybe it was MVEL?)) that'll indicate the el to be
> used.
>
>
> <s:if test="%{(#fieldNameStatus.index % 10)==0}">xxxxx</s:if>
>
> -Dale
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: RE: Calculate module of index in Struts2 iterator
Posted by Dave Newton <da...@gmail.com>.
Huh? Regex libraries?
On Dec 24, 2010 9:14 AM, "Martin Gainty" <mg...@hotmail.com> wrote:
>
> good advice for portability for regular-expression libraries
>
> any someone put that into the docs?
>
> Happy Christmas and Merry New Year,
> Martin Gainty
> ______________________________________________
> Jogi és Bizalmassági kinyilatkoztatás/Verzicht und
Vertraulichkeitanmerkung/Note de déni et de confidentialité
> Ez az
> üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
> jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
> készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
> semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
> könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
> ezen üzenet tartalma miatt.
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
dient lediglich dem Austausch von Informationen und entfaltet keine
rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire
informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
de ceci est interdite. Ce message sert à l'information seulement et n'aura
pas n'importe quel effet légalement obligatoire. Étant donné que les email
peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
aucune responsabilité pour le contenu fourni.
>
>
>
>
>> Date: Fri, 24 Dec 2010 09:05:05 -0500
>> From: dale@newfield.org
>> To: user@struts.apache.org
>> Subject: Re: Calculate module of index in Struts2 iterator
>>
>> On 12/24/10 6:15 AM, JOSE L MARTINEZ-AVIAL wrote:
>> > <s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
>>
>> I guess I've not been around on this list much lately (darned work :-/
>> ). So my constant harping about this hasn't been so constant:
>>
>> I *really* advise people to always use %{} when writing OGNL in a taglib
>> attribute. It makes it clear what is to be evaluated as an OGNL
>> expression and what's just text. It's not just for readability and
>> maintainability -- it's also to future-proof your code. In the future
>> struts may be able to use more ELs than just OGNL, and its the character
>> out front (% = OGNL; $ = EL; # = JUEL (IIRC -- maybe it was MVEL?))
>> that'll indicate the el to be used.
>>
>> <s:if test="%{(#fieldNameStatus.index % 10)==0}">xxxxx</s:if>
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
RE: Calculate module of index in Struts2 iterator
Posted by Martin Gainty <mg...@hotmail.com>.
good advice for portability for regular-expression libraries
any someone put that into the docs?
Happy Christmas and Merry New Year,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Fri, 24 Dec 2010 09:05:05 -0500
> From: dale@newfield.org
> To: user@struts.apache.org
> Subject: Re: Calculate module of index in Struts2 iterator
>
> On 12/24/10 6:15 AM, JOSE L MARTINEZ-AVIAL wrote:
> > <s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
>
> I guess I've not been around on this list much lately (darned work :-/
> ). So my constant harping about this hasn't been so constant:
>
> I *really* advise people to always use %{} when writing OGNL in a taglib
> attribute. It makes it clear what is to be evaluated as an OGNL
> expression and what's just text. It's not just for readability and
> maintainability -- it's also to future-proof your code. In the future
> struts may be able to use more ELs than just OGNL, and its the character
> out front (% = OGNL; $ = EL; # = JUEL (IIRC -- maybe it was MVEL?))
> that'll indicate the el to be used.
>
> <s:if test="%{(#fieldNameStatus.index % 10)==0}">xxxxx</s:if>
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
Re: Calculate module of index in Struts2 iterator
Posted by Dale Newfield <da...@newfield.org>.
On 12/24/10 6:15 AM, JOSE L MARTINEZ-AVIAL wrote:
> <s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
I guess I've not been around on this list much lately (darned work :-/
). So my constant harping about this hasn't been so constant:
I *really* advise people to always use %{} when writing OGNL in a taglib
attribute. It makes it clear what is to be evaluated as an OGNL
expression and what's just text. It's not just for readability and
maintainability -- it's also to future-proof your code. In the future
struts may be able to use more ELs than just OGNL, and its the character
out front (% = OGNL; $ = EL; # = JUEL (IIRC -- maybe it was MVEL?))
that'll indicate the el to be used.
<s:if test="%{(#fieldNameStatus.index % 10)==0}">xxxxx</s:if>
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calculate module of index in Struts2 iterator
Posted by Li Ying <li...@gmail.com>.
That's just wired.
The first idea in my head was, may be there is lacks of brackets in
your expression.
But then I checked the document of OGNL:
http://www.opensymphony.com/ognl/html/LanguageGuide/apa.html
Accordinting to this document,
the operator [%] has higher precedence than operator [==].
Which means, the original expression without brackets should be same
as the expression with brackets.
So, I did not talk about the brackets thing.
But of cause, it will be much more better to add the brackets.
2010/12/24 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>:
> I had to put the expression between brackets:
>
> <s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
>
> Thanks
>
> JL
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calculate module of index in Struts2 iterator
Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
I had to put the expression between brackets:
<s:if test="(#fieldNameStatus.index % 10 )==0">xxxxx</s:if>
Thanks
JL
2010/12/21 Li Ying <li...@gmail.com>
> You can put the following debug code in your jsp:
>
> <s:property value="#fieldNameStatus.index" />
> <s:property value="#fieldNameStatus.index % 10" />
> <s:property value="#fieldNameStatus.index % 10 ==0" />
>
> It may help you find out what the result of expression is.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Calculate module of index in Struts2 iterator
Posted by Li Ying <li...@gmail.com>.
You can put the following debug code in your jsp:
<s:property value="#fieldNameStatus.index" />
<s:property value="#fieldNameStatus.index % 10" />
<s:property value="#fieldNameStatus.index % 10 ==0" />
It may help you find out what the result of expression is.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org