You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bhaarat Sharma <bh...@gmail.com> on 2009/08/05 17:35:50 UTC

struts2 ognl confusion

I have the following code in a jsp
Line1: <s:iterator value="questions" status="status">
Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
Line3:        <div style="color: red; padding-bottom: 5px;">Print
Something</div>
Line4:    </s:if>
Line5:</s:iterator>

On Line1 questions is a list.  This list contains object of class Exam.
Class Exam has a getter/setter questionId
On Line2 incorrectQs is a list.  This list contains strings.

I am checking to see if list in Line2 contains a questionId that is in
questions list on line1.

Is this the best way to do this?

the code seems to be working but 'randomly' sometimes Line2 never seems to
be true ...when we know it IS true.

I just want to make sure with some experienced people whether this is the
way to achieve this?

Re: struts2 ognl confusion

Posted by mu...@aol.com.
 is it (questionId) human generated 9I am thinking leading/trailing white space etc).
Really clutching at straws but somehow the questionid must occasionally be different ...
Chris


 


 

-----Original Message-----
From: Bhaarat Sharma <bh...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wed, Aug 5, 2009 1:41 pm
Subject: Re: struts2 ognl confusion










questionId is just a string. so dont think its equals or hash problem.
wes, what you suggested I've put that in place and testing to see if error
comes again.

On Wed, Aug 5, 2009 at 1:35 PM, <mu...@aol.com> wrote:

>
>  what type is questionId? You might have a problem with the
> equals() in it.
> Chris
>
>
>
>
>
>
>
> -----Original Message-----
> From: Wes Wannemacher <we...@wantii.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wed, Aug 5, 2009 1:09 pm
> Subject: Re: struts2 ognl confusion
>
>
>
>
>
>
>
>
>
>
> I would try to fiddle around with incorrectQs to see why .contains
> isn't working... I'm guessing that if you iterate both lists, although
> not efficient, you might get better results -
>
> <s:iterator value="questions" id="question">
> <s:iterator value="incorrectQs" id="incorrectQ">
>  <s:if test='%{#incorrectQ == #question.questionId}'>
>    <div style="color: red; padding-bottom: 5px;">Print Something</div>
>  </s:if>
> </s:iterator>
> </s:iterator>
>
>
>
> On Wed, Aug 5, 2009 at 12:22 PM, Bhaarat Sharma<bh...@gmail.com>
> wrote:
> > looks like it is not working only in contains.I tried the following:
> >
> > <s:iterator value="questions" status="status" id="question">
> > ? ? ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
> > ? ? ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
> > Something</div>
> > ? ? ? ?</s:if>
> > ? ? ? ?<s:else>
> > ? ? ? ? ? ? <s:property value="#question.questionId"/> <!--Line 6-->
> > ? ? ? ?</s:else>
> > </s:iterator>
> >
> > Line 6 prints fine and prints questionId...:(
> >
> > On Wed, Aug 5, 2009 at 12:09 PM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
> >
> >> thanks for the explanation chris. but using what you suggested is not
> >> making Print Something appear even once. so the test statement is never
> >> evaluated to true. ...leading me to suspect that ognl expression is not
> >> working.
> >> I am not sure whether the random error that is happening for us is being
> >> caused by using ${}. Now that you mentioned it is a security concern to
> use
> >> that expression under s: tags I am ready to change it to #...considering
> I
> >> find the syntax to do it..
> >>
> >>
> >> On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <thechrispratt@gmail.com
> >wrote:
> >>
> >>> You must be using a fairly old version of Struts 2. ?The difference
> >>> between
> >>> the ${} and the # versions is that the ${} is a JSTL EL expression that
> is
> >>> no longer allowed inside struts (s:) tags for security reasons. ?The #
> >>> version is OGNL and references the variable that Wes tried to define.
> ?Try
> >>> using the id attribute instead of the var attribute. ?So something more
> >>> like
> >>> this:
> >>>
> >>> <s:iterator value="%{questions}" status="status" id="question">
> >>> ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
> >>> ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
> Something</div>
> >>> ? ?</s:if>
> >>> </s:iterator>
> >>>
> >>> I like to make it obvious which attributes use OGNL by enclosing them
> in
> >>> %{}
> >>> ? (*Chris*)
> >>>
> >>> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
> >>> wrote:
> >>>
> >>> > oh and attribute 'var' seems to be invalid according to the TLD
> >>> >
> >>> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bhaarat.s@gmail.com
> >
> >>> > wrote:
> >>> >
> >>> > > ok thanks Wes. yeah that is def. more readable.
> >>> > > could you please tell me what the difference is in doing
> >>> > > ? ? <s:if test='incorrectQs.contains("${questionId}")'>
> >>> > > VS.
> >>> > > ? ? <s:if test='incorrectQs.contains(#question.questionId)'>
> >>> > >
> >>> > > beside the question.questionId part. I am more concerned about
> >>> difference
> >>> > > in '$' vs. '#'
> >>> > >
> >>> > >
> >>> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> >>> > wrote:
> >>> > >
> >>> > >> I think this would be more readable -
> >>> > >>
> >>> > >> <s:iterator value="questions" status="status" var="question">
> >>> > >> ? ?<s:if test='incorrectQs.contains(#question.questionId)'>
> >>> > >> ? ? ? ? <div style="color: red; padding-bottom: 5px;">Print
> >>> > >> Something</div>
> >>> > >> ? ? </s:if>
> >>> > >> </s:iterator>
> >>> > >>
> >>> > >> -Wes
> >>> > >>
> >>> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<
> bhaarat.s@gmail.com>
> >>> > >> wrote:
> >>> > >> > I have the following code in a jsp
> >>> > >> > Line1: <s:iterator value="questions" status="status">
> >>> > >> > Line2: ? ?<s:if test='incorrectQs.contains("${questionId}")'>
> >>> > >> > Line3: ? ? ? ?<div style="color: red; padding-bottom:
> 5px;">Print
> >>> > >> > Something</div>
> >>> > >> > Line4: ? ?</s:if>
> >>> > >> > Line5:</s:iterator>
> >>> > >> >
> >>> > >> > On Line1 questions is a list. ?This list contains object of
> class
> >>> > Exam.
> >>> > >> > Class Exam has a getter/setter questionId
> >>> > >> > On Line2 incorrectQs is a list. ?This list contains strings.
> >>> > >> >
> >>> > >> > I am checking to see if list in Line2 contains a questionId that
> is
> >>> in
> >>> > >> > questions list on line1.
> >>> > >> >
> >>> > >> > Is this the best way to do this?
> >>> > >> >
> >>> > >> > the code seems to be working but 'randomly' sometimes Line2
> never
> >>> > seems
> >>> > >> to
> >>> > >> > be true ...when we know it IS true.
> >>> > >> >
> >>> > >> > I just want to make sure with some experienced people whether
> this
> >>> is
> >>> > >> the
> >>> > >> > way to achieve this?
> >>> > >> >
> >>> > >>
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Wes Wannemacher
> >>> > >>
> >>> > >> Head Engineer, WanTii, Inc.
> >>> > >> Need Training? Struts, Spring, Maven, Tomcat...
> >>> > >> Ask me for a quote!
> >>> > >>
> >>> > >>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> > >> For additional commands, e-mail: user-help@struts.apache.org
> >>> > >>
> >>> > >>
> >>> > >
> >>> >
> >>>
> >>
> >>
> >
>
>
>
> --
> Wes Wannemacher
>
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
>



 


Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
questionId is just a string. so dont think its equals or hash problem.
wes, what you suggested I've put that in place and testing to see if error
comes again.

On Wed, Aug 5, 2009 at 1:35 PM, <mu...@aol.com> wrote:

>
>  what type is questionId? You might have a problem with the
> equals() in it.
> Chris
>
>
>
>
>
>
>
> -----Original Message-----
> From: Wes Wannemacher <we...@wantii.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wed, Aug 5, 2009 1:09 pm
> Subject: Re: struts2 ognl confusion
>
>
>
>
>
>
>
>
>
>
> I would try to fiddle around with incorrectQs to see why .contains
> isn't working... I'm guessing that if you iterate both lists, although
> not efficient, you might get better results -
>
> <s:iterator value="questions" id="question">
> <s:iterator value="incorrectQs" id="incorrectQ">
>  <s:if test='%{#incorrectQ == #question.questionId}'>
>    <div style="color: red; padding-bottom: 5px;">Print Something</div>
>  </s:if>
> </s:iterator>
> </s:iterator>
>
>
>
> On Wed, Aug 5, 2009 at 12:22 PM, Bhaarat Sharma<bh...@gmail.com>
> wrote:
> > looks like it is not working only in contains.I tried the following:
> >
> > <s:iterator value="questions" status="status" id="question">
> > ? ? ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
> > ? ? ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
> > Something</div>
> > ? ? ? ?</s:if>
> > ? ? ? ?<s:else>
> > ? ? ? ? ? ? <s:property value="#question.questionId"/> <!--Line 6-->
> > ? ? ? ?</s:else>
> > </s:iterator>
> >
> > Line 6 prints fine and prints questionId...:(
> >
> > On Wed, Aug 5, 2009 at 12:09 PM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
> >
> >> thanks for the explanation chris. but using what you suggested is not
> >> making Print Something appear even once. so the test statement is never
> >> evaluated to true. ...leading me to suspect that ognl expression is not
> >> working.
> >> I am not sure whether the random error that is happening for us is being
> >> caused by using ${}. Now that you mentioned it is a security concern to
> use
> >> that expression under s: tags I am ready to change it to #...considering
> I
> >> find the syntax to do it..
> >>
> >>
> >> On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <thechrispratt@gmail.com
> >wrote:
> >>
> >>> You must be using a fairly old version of Struts 2. ?The difference
> >>> between
> >>> the ${} and the # versions is that the ${} is a JSTL EL expression that
> is
> >>> no longer allowed inside struts (s:) tags for security reasons. ?The #
> >>> version is OGNL and references the variable that Wes tried to define.
> ?Try
> >>> using the id attribute instead of the var attribute. ?So something more
> >>> like
> >>> this:
> >>>
> >>> <s:iterator value="%{questions}" status="status" id="question">
> >>> ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
> >>> ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
> Something</div>
> >>> ? ?</s:if>
> >>> </s:iterator>
> >>>
> >>> I like to make it obvious which attributes use OGNL by enclosing them
> in
> >>> %{}
> >>> ? (*Chris*)
> >>>
> >>> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
> >>> wrote:
> >>>
> >>> > oh and attribute 'var' seems to be invalid according to the TLD
> >>> >
> >>> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bhaarat.s@gmail.com
> >
> >>> > wrote:
> >>> >
> >>> > > ok thanks Wes. yeah that is def. more readable.
> >>> > > could you please tell me what the difference is in doing
> >>> > > ? ? <s:if test='incorrectQs.contains("${questionId}")'>
> >>> > > VS.
> >>> > > ? ? <s:if test='incorrectQs.contains(#question.questionId)'>
> >>> > >
> >>> > > beside the question.questionId part. I am more concerned about
> >>> difference
> >>> > > in '$' vs. '#'
> >>> > >
> >>> > >
> >>> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> >>> > wrote:
> >>> > >
> >>> > >> I think this would be more readable -
> >>> > >>
> >>> > >> <s:iterator value="questions" status="status" var="question">
> >>> > >> ? ?<s:if test='incorrectQs.contains(#question.questionId)'>
> >>> > >> ? ? ? ? <div style="color: red; padding-bottom: 5px;">Print
> >>> > >> Something</div>
> >>> > >> ? ? </s:if>
> >>> > >> </s:iterator>
> >>> > >>
> >>> > >> -Wes
> >>> > >>
> >>> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<
> bhaarat.s@gmail.com>
> >>> > >> wrote:
> >>> > >> > I have the following code in a jsp
> >>> > >> > Line1: <s:iterator value="questions" status="status">
> >>> > >> > Line2: ? ?<s:if test='incorrectQs.contains("${questionId}")'>
> >>> > >> > Line3: ? ? ? ?<div style="color: red; padding-bottom:
> 5px;">Print
> >>> > >> > Something</div>
> >>> > >> > Line4: ? ?</s:if>
> >>> > >> > Line5:</s:iterator>
> >>> > >> >
> >>> > >> > On Line1 questions is a list. ?This list contains object of
> class
> >>> > Exam.
> >>> > >> > Class Exam has a getter/setter questionId
> >>> > >> > On Line2 incorrectQs is a list. ?This list contains strings.
> >>> > >> >
> >>> > >> > I am checking to see if list in Line2 contains a questionId that
> is
> >>> in
> >>> > >> > questions list on line1.
> >>> > >> >
> >>> > >> > Is this the best way to do this?
> >>> > >> >
> >>> > >> > the code seems to be working but 'randomly' sometimes Line2
> never
> >>> > seems
> >>> > >> to
> >>> > >> > be true ...when we know it IS true.
> >>> > >> >
> >>> > >> > I just want to make sure with some experienced people whether
> this
> >>> is
> >>> > >> the
> >>> > >> > way to achieve this?
> >>> > >> >
> >>> > >>
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Wes Wannemacher
> >>> > >>
> >>> > >> Head Engineer, WanTii, Inc.
> >>> > >> Need Training? Struts, Spring, Maven, Tomcat...
> >>> > >> Ask me for a quote!
> >>> > >>
> >>> > >>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> > >> For additional commands, e-mail: user-help@struts.apache.org
> >>> > >>
> >>> > >>
> >>> > >
> >>> >
> >>>
> >>
> >>
> >
>
>
>
> --
> Wes Wannemacher
>
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
>

Re: struts2 ognl confusion

Posted by mu...@aol.com.
 what type is questionId? You might have a problem with the 
equals() in it.
Chris


 


 

-----Original Message-----
From: Wes Wannemacher <we...@wantii.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wed, Aug 5, 2009 1:09 pm
Subject: Re: struts2 ognl confusion










I would try to fiddle around with incorrectQs to see why .contains
isn't working... I'm guessing that if you iterate both lists, although
not efficient, you might get better results -

<s:iterator value="questions" id="question">
<s:iterator value="incorrectQs" id="incorrectQ">
  <s:if test='%{#incorrectQ == #question.questionId}'>
    <div style="color: red; padding-bottom: 5px;">Print Something</div>
  </s:if>
</s:iterator>
</s:iterator>



On Wed, Aug 5, 2009 at 12:22 PM, Bhaarat Sharma<bh...@gmail.com> wrote:
> looks like it is not working only in contains.I tried the following:
>
> <s:iterator value="questions" status="status" id="question">
> ? ? ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
> ? ? ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
> Something</div>
> ? ? ? ?</s:if>
> ? ? ? ?<s:else>
> ? ? ? ? ? ? <s:property value="#question.questionId"/> <!--Line 6-->
> ? ? ? ?</s:else>
> </s:iterator>
>
> Line 6 prints fine and prints questionId...:(
>
> On Wed, Aug 5, 2009 at 12:09 PM, Bhaarat Sharma <bh...@gmail.com> wrote:
>
>> thanks for the explanation chris. but using what you suggested is not
>> making Print Something appear even once. so the test statement is never
>> evaluated to true. ...leading me to suspect that ognl expression is not
>> working.
>> I am not sure whether the random error that is happening for us is being
>> caused by using ${}. Now that you mentioned it is a security concern to use
>> that expression under s: tags I am ready to change it to #...considering I
>> find the syntax to do it..
>>
>>
>> On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <th...@gmail.com>wrote:
>>
>>> You must be using a fairly old version of Struts 2. ?The difference
>>> between
>>> the ${} and the # versions is that the ${} is a JSTL EL expression that is
>>> no longer allowed inside struts (s:) tags for security reasons. ?The #
>>> version is OGNL and references the variable that Wes tried to define. ?Try
>>> using the id attribute instead of the var attribute. ?So something more
>>> like
>>> this:
>>>
>>> <s:iterator value="%{questions}" status="status" id="question">
>>> ? ?<s:if test='%{incorrectQs.contains(#question.questionId)}'>
>>> ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print Something</div>
>>> ? ?</s:if>
>>> </s:iterator>
>>>
>>> I like to make it obvious which attributes use OGNL by enclosing them in
>>> %{}
>>> ? (*Chris*)
>>>
>>> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
>>> wrote:
>>>
>>> > oh and attribute 'var' seems to be invalid according to the TLD
>>> >
>>> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
>>> > wrote:
>>> >
>>> > > ok thanks Wes. yeah that is def. more readable.
>>> > > could you please tell me what the difference is in doing
>>> > > ? ? <s:if test='incorrectQs.contains("${questionId}")'>
>>> > > VS.
>>> > > ? ? <s:if test='incorrectQs.contains(#question.questionId)'>
>>> > >
>>> > > beside the question.questionId part. I am more concerned about
>>> difference
>>> > > in '$' vs. '#'
>>> > >
>>> > >
>>> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
>>> > wrote:
>>> > >
>>> > >> I think this would be more readable -
>>> > >>
>>> > >> <s:iterator value="questions" status="status" var="question">
>>> > >> ? ?<s:if test='incorrectQs.contains(#question.questionId)'>
>>> > >> ? ? ? ? <div style="color: red; padding-bottom: 5px;">Print
>>> > >> Something</div>
>>> > >> ? ? </s:if>
>>> > >> </s:iterator>
>>> > >>
>>> > >> -Wes
>>> > >>
>>> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
>>> > >> wrote:
>>> > >> > I have the following code in a jsp
>>> > >> > Line1: <s:iterator value="questions" status="status">
>>> > >> > Line2: ? ?<s:if test='incorrectQs.contains("${questionId}")'>
>>> > >> > Line3: ? ? ? ?<div style="color: red; padding-bottom: 5px;">Print
>>> > >> > Something</div>
>>> > >> > Line4: ? ?</s:if>
>>> > >> > Line5:</s:iterator>
>>> > >> >
>>> > >> > On Line1 questions is a list. ?This list contains object of class
>>> > Exam.
>>> > >> > Class Exam has a getter/setter questionId
>>> > >> > On Line2 incorrectQs is a list. ?This list contains strings.
>>> > >> >
>>> > >> > I am checking to see if list in Line2 contains a questionId that is
>>> in
>>> > >> > questions list on line1.
>>> > >> >
>>> > >> > Is this the best way to do this?
>>> > >> >
>>> > >> > the code seems to be working but 'randomly' sometimes Line2 never
>>> > seems
>>> > >> to
>>> > >> > be true ...when we know it IS true.
>>> > >> >
>>> > >> > I just want to make sure with some experienced people whether this
>>> is
>>> > >> the
>>> > >> > way to achieve this?
>>> > >> >
>>> > >>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Wes Wannemacher
>>> > >>
>>> > >> Head Engineer, WanTii, Inc.
>>> > >> Need Training? Struts, Spring, Maven, Tomcat...
>>> > >> Ask me for a quote!
>>> > >>
>>> > >> ---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > >> For additional commands, e-mail: user-help@struts.apache.org
>>> > >>
>>> > >>
>>> > >
>>> >
>>>
>>
>>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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



 


Re: struts2 ognl confusion

Posted by Wes Wannemacher <we...@wantii.com>.
I would try to fiddle around with incorrectQs to see why .contains
isn't working... I'm guessing that if you iterate both lists, although
not efficient, you might get better results -

<s:iterator value="questions" id="question">
<s:iterator value="incorrectQs" id="incorrectQ">
  <s:if test='%{#incorrectQ == #question.questionId}'>
    <div style="color: red; padding-bottom: 5px;">Print Something</div>
  </s:if>
</s:iterator>
</s:iterator>



On Wed, Aug 5, 2009 at 12:22 PM, Bhaarat Sharma<bh...@gmail.com> wrote:
> looks like it is not working only in contains.I tried the following:
>
> <s:iterator value="questions" status="status" id="question">
>        <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>            <div style="color: red; padding-bottom: 5px;">Print
> Something</div>
>        </s:if>
>        <s:else>
>             <s:property value="#question.questionId"/> <!--Line 6-->
>        </s:else>
> </s:iterator>
>
> Line 6 prints fine and prints questionId...:(
>
> On Wed, Aug 5, 2009 at 12:09 PM, Bhaarat Sharma <bh...@gmail.com> wrote:
>
>> thanks for the explanation chris. but using what you suggested is not
>> making Print Something appear even once. so the test statement is never
>> evaluated to true. ...leading me to suspect that ognl expression is not
>> working.
>> I am not sure whether the random error that is happening for us is being
>> caused by using ${}. Now that you mentioned it is a security concern to use
>> that expression under s: tags I am ready to change it to #...considering I
>> find the syntax to do it..
>>
>>
>> On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <th...@gmail.com>wrote:
>>
>>> You must be using a fairly old version of Struts 2.  The difference
>>> between
>>> the ${} and the # versions is that the ${} is a JSTL EL expression that is
>>> no longer allowed inside struts (s:) tags for security reasons.  The #
>>> version is OGNL and references the variable that Wes tried to define.  Try
>>> using the id attribute instead of the var attribute.  So something more
>>> like
>>> this:
>>>
>>> <s:iterator value="%{questions}" status="status" id="question">
>>>    <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>>>        <div style="color: red; padding-bottom: 5px;">Print Something</div>
>>>    </s:if>
>>> </s:iterator>
>>>
>>> I like to make it obvious which attributes use OGNL by enclosing them in
>>> %{}
>>>   (*Chris*)
>>>
>>> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
>>> wrote:
>>>
>>> > oh and attribute 'var' seems to be invalid according to the TLD
>>> >
>>> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
>>> > wrote:
>>> >
>>> > > ok thanks Wes. yeah that is def. more readable.
>>> > > could you please tell me what the difference is in doing
>>> > >     <s:if test='incorrectQs.contains("${questionId}")'>
>>> > > VS.
>>> > >     <s:if test='incorrectQs.contains(#question.questionId)'>
>>> > >
>>> > > beside the question.questionId part. I am more concerned about
>>> difference
>>> > > in '$' vs. '#'
>>> > >
>>> > >
>>> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
>>> > wrote:
>>> > >
>>> > >> I think this would be more readable -
>>> > >>
>>> > >> <s:iterator value="questions" status="status" var="question">
>>> > >>    <s:if test='incorrectQs.contains(#question.questionId)'>
>>> > >>         <div style="color: red; padding-bottom: 5px;">Print
>>> > >> Something</div>
>>> > >>     </s:if>
>>> > >> </s:iterator>
>>> > >>
>>> > >> -Wes
>>> > >>
>>> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
>>> > >> wrote:
>>> > >> > I have the following code in a jsp
>>> > >> > Line1: <s:iterator value="questions" status="status">
>>> > >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
>>> > >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
>>> > >> > Something</div>
>>> > >> > Line4:    </s:if>
>>> > >> > Line5:</s:iterator>
>>> > >> >
>>> > >> > On Line1 questions is a list.  This list contains object of class
>>> > Exam.
>>> > >> > Class Exam has a getter/setter questionId
>>> > >> > On Line2 incorrectQs is a list.  This list contains strings.
>>> > >> >
>>> > >> > I am checking to see if list in Line2 contains a questionId that is
>>> in
>>> > >> > questions list on line1.
>>> > >> >
>>> > >> > Is this the best way to do this?
>>> > >> >
>>> > >> > the code seems to be working but 'randomly' sometimes Line2 never
>>> > seems
>>> > >> to
>>> > >> > be true ...when we know it IS true.
>>> > >> >
>>> > >> > I just want to make sure with some experienced people whether this
>>> is
>>> > >> the
>>> > >> > way to achieve this?
>>> > >> >
>>> > >>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Wes Wannemacher
>>> > >>
>>> > >> Head Engineer, WanTii, Inc.
>>> > >> Need Training? Struts, Spring, Maven, Tomcat...
>>> > >> Ask me for a quote!
>>> > >>
>>> > >> ---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > >> For additional commands, e-mail: user-help@struts.apache.org
>>> > >>
>>> > >>
>>> > >
>>> >
>>>
>>
>>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
looks like it is not working only in contains.I tried the following:

<s:iterator value="questions" status="status" id="question">
        <s:if test='%{incorrectQs.contains(#question.questionId)}'>
            <div style="color: red; padding-bottom: 5px;">Print
Something</div>
        </s:if>
        <s:else>
             <s:property value="#question.questionId"/> <!--Line 6-->
        </s:else>
</s:iterator>

Line 6 prints fine and prints questionId...:(

On Wed, Aug 5, 2009 at 12:09 PM, Bhaarat Sharma <bh...@gmail.com> wrote:

> thanks for the explanation chris. but using what you suggested is not
> making Print Something appear even once. so the test statement is never
> evaluated to true. ...leading me to suspect that ognl expression is not
> working.
> I am not sure whether the random error that is happening for us is being
> caused by using ${}. Now that you mentioned it is a security concern to use
> that expression under s: tags I am ready to change it to #...considering I
> find the syntax to do it..
>
>
> On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <th...@gmail.com>wrote:
>
>> You must be using a fairly old version of Struts 2.  The difference
>> between
>> the ${} and the # versions is that the ${} is a JSTL EL expression that is
>> no longer allowed inside struts (s:) tags for security reasons.  The #
>> version is OGNL and references the variable that Wes tried to define.  Try
>> using the id attribute instead of the var attribute.  So something more
>> like
>> this:
>>
>> <s:iterator value="%{questions}" status="status" id="question">
>>    <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>>        <div style="color: red; padding-bottom: 5px;">Print Something</div>
>>    </s:if>
>> </s:iterator>
>>
>> I like to make it obvious which attributes use OGNL by enclosing them in
>> %{}
>>   (*Chris*)
>>
>> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
>> wrote:
>>
>> > oh and attribute 'var' seems to be invalid according to the TLD
>> >
>> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
>> > wrote:
>> >
>> > > ok thanks Wes. yeah that is def. more readable.
>> > > could you please tell me what the difference is in doing
>> > >     <s:if test='incorrectQs.contains("${questionId}")'>
>> > > VS.
>> > >     <s:if test='incorrectQs.contains(#question.questionId)'>
>> > >
>> > > beside the question.questionId part. I am more concerned about
>> difference
>> > > in '$' vs. '#'
>> > >
>> > >
>> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
>> > wrote:
>> > >
>> > >> I think this would be more readable -
>> > >>
>> > >> <s:iterator value="questions" status="status" var="question">
>> > >>    <s:if test='incorrectQs.contains(#question.questionId)'>
>> > >>         <div style="color: red; padding-bottom: 5px;">Print
>> > >> Something</div>
>> > >>     </s:if>
>> > >> </s:iterator>
>> > >>
>> > >> -Wes
>> > >>
>> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
>> > >> wrote:
>> > >> > I have the following code in a jsp
>> > >> > Line1: <s:iterator value="questions" status="status">
>> > >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
>> > >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
>> > >> > Something</div>
>> > >> > Line4:    </s:if>
>> > >> > Line5:</s:iterator>
>> > >> >
>> > >> > On Line1 questions is a list.  This list contains object of class
>> > Exam.
>> > >> > Class Exam has a getter/setter questionId
>> > >> > On Line2 incorrectQs is a list.  This list contains strings.
>> > >> >
>> > >> > I am checking to see if list in Line2 contains a questionId that is
>> in
>> > >> > questions list on line1.
>> > >> >
>> > >> > Is this the best way to do this?
>> > >> >
>> > >> > the code seems to be working but 'randomly' sometimes Line2 never
>> > seems
>> > >> to
>> > >> > be true ...when we know it IS true.
>> > >> >
>> > >> > I just want to make sure with some experienced people whether this
>> is
>> > >> the
>> > >> > way to achieve this?
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> Wes Wannemacher
>> > >>
>> > >> Head Engineer, WanTii, Inc.
>> > >> Need Training? Struts, Spring, Maven, Tomcat...
>> > >> Ask me for a quote!
>> > >>
>> > >> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > >> For additional commands, e-mail: user-help@struts.apache.org
>> > >>
>> > >>
>> > >
>> >
>>
>
>

Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
thanks for the explanation chris. but using what you suggested is not making
Print Something appear even once. so the test statement is never evaluated
to true. ...leading me to suspect that ognl expression is not working.
I am not sure whether the random error that is happening for us is being
caused by using ${}. Now that you mentioned it is a security concern to use
that expression under s: tags I am ready to change it to #...considering I
find the syntax to do it..

On Wed, Aug 5, 2009 at 11:54 AM, Chris Pratt <th...@gmail.com>wrote:

> You must be using a fairly old version of Struts 2.  The difference between
> the ${} and the # versions is that the ${} is a JSTL EL expression that is
> no longer allowed inside struts (s:) tags for security reasons.  The #
> version is OGNL and references the variable that Wes tried to define.  Try
> using the id attribute instead of the var attribute.  So something more
> like
> this:
>
> <s:iterator value="%{questions}" status="status" id="question">
>    <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>        <div style="color: red; padding-bottom: 5px;">Print Something</div>
>    </s:if>
> </s:iterator>
>
> I like to make it obvious which attributes use OGNL by enclosing them in
> %{}
>   (*Chris*)
>
> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
>
> > oh and attribute 'var' seems to be invalid according to the TLD
> >
> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
> > wrote:
> >
> > > ok thanks Wes. yeah that is def. more readable.
> > > could you please tell me what the difference is in doing
> > >     <s:if test='incorrectQs.contains("${questionId}")'>
> > > VS.
> > >     <s:if test='incorrectQs.contains(#question.questionId)'>
> > >
> > > beside the question.questionId part. I am more concerned about
> difference
> > > in '$' vs. '#'
> > >
> > >
> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> > wrote:
> > >
> > >> I think this would be more readable -
> > >>
> > >> <s:iterator value="questions" status="status" var="question">
> > >>    <s:if test='incorrectQs.contains(#question.questionId)'>
> > >>         <div style="color: red; padding-bottom: 5px;">Print
> > >> Something</div>
> > >>     </s:if>
> > >> </s:iterator>
> > >>
> > >> -Wes
> > >>
> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> > >> wrote:
> > >> > I have the following code in a jsp
> > >> > Line1: <s:iterator value="questions" status="status">
> > >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> > >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> > >> > Something</div>
> > >> > Line4:    </s:if>
> > >> > Line5:</s:iterator>
> > >> >
> > >> > On Line1 questions is a list.  This list contains object of class
> > Exam.
> > >> > Class Exam has a getter/setter questionId
> > >> > On Line2 incorrectQs is a list.  This list contains strings.
> > >> >
> > >> > I am checking to see if list in Line2 contains a questionId that is
> in
> > >> > questions list on line1.
> > >> >
> > >> > Is this the best way to do this?
> > >> >
> > >> > the code seems to be working but 'randomly' sometimes Line2 never
> > seems
> > >> to
> > >> > be true ...when we know it IS true.
> > >> >
> > >> > I just want to make sure with some experienced people whether this
> is
> > >> the
> > >> > way to achieve this?
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Wes Wannemacher
> > >>
> > >> Head Engineer, WanTii, Inc.
> > >> Need Training? Struts, Spring, Maven, Tomcat...
> > >> Ask me for a quote!
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> > >
> >
>

Re: struts2 ognl confusion

Posted by Chris Pratt <th...@gmail.com>.
That's because that document applies to the 2.1.x version of Struts 2, if
${} was working inside of the struts tags you're at least back before 2.0.9
and the var tag didn't exist (so the id tag was not yet deprecated).
  (*Chris*)

On Wed, Aug 5, 2009 at 9:53 AM, <ma...@yahoo.com> wrote:

> but in this document
> http://struts.apache.org/2.1.6/docs/iterator.html
> id attribute is deprecated.
>
> Louis
>
>
> ________________________________
> From: Chris Pratt <th...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wednesday, August 5, 2009 4:54:31 PM
> Subject: Re: struts2 ognl confusion
>
> You must be using a fairly old version of Struts 2.  The difference between
> the ${} and the # versions is that the ${} is a JSTL EL expression that is
> no longer allowed inside struts (s:) tags for security reasons.  The #
> version is OGNL and references the variable that Wes tried to define.  Try
> using the id attribute instead of the var attribute.  So something more
> like
> this:
>
> <s:iterator value="%{questions}" status="status" id="question">
>   <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>        <div style="color: red; padding-bottom: 5px;">Print Something</div>
>    </s:if>
> </s:iterator>
>
> I like to make it obvious which attributes use OGNL by enclosing them in
> %{}
>  (*Chris*)
>
> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
>
> > oh and attribute 'var' seems to be invalid according to the TLD
> >
> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
> > wrote:
> >
> > > ok thanks Wes. yeah that is def. more readable.
> > > could you please tell me what the difference is in doing
> > >     <s:if test='incorrectQs.contains("${questionId}")'>
> > > VS.
> > >     <s:if test='incorrectQs.contains(#question.questionId)'>
> > >
> > > beside the question.questionId part. I am more concerned about
> difference
> > > in '$' vs. '#'
> > >
> > >
> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> > wrote:
> > >
> > >> I think this would be more readable -
> > >>
> > >> <s:iterator value="questions" status="status" var="question">
> > >>    <s:if test='incorrectQs.contains(#question.questionId)'>
> > >>         <div style="color: red; padding-bottom: 5px;">Print
> > >> Something</div>
> > >>     </s:if>
> > >> </s:iterator>
> > >>
> > >> -Wes
> > >>
> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> > >> wrote:
> > >> > I have the following code in a jsp
> > >> > Line1: <s:iterator value="questions" status="status">
> > >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> > >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> > >> > Something</div>
> > >> > Line4:    </s:if>
> > >> > Line5:</s:iterator>
> > >> >
> > >> > On Line1 questions is a list.  This list contains object of class
> > Exam.
> > >> > Class Exam has a getter/setter questionId
> > >> > On Line2 incorrectQs is a list.  This list contains strings.
> > >> >
> > >> > I am checking to see if list in Line2 contains a questionId that is
> in
> > >> > questions list on line1.
> > >> >
> > >> > Is this the best way to do this?
> > >> >
> > >> > the code seems to be working but 'randomly' sometimes Line2 never
> > seems
> > >> to
> > >> > be true ...when we know it IS true.
> > >> >
> > >> > I just want to make sure with some experienced people whether this
> is
> > >> the
> > >> > way to achieve this?
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Wes Wannemacher
> > >>
> > >> Head Engineer, WanTii, Inc.
> > >> Need Training? Struts, Spring, Maven, Tomcat...
> > >> Ask me for a quote!
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> > >
> >
>

Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
but my version < 2.1.6

On Wed, Aug 5, 2009 at 12:53 PM, <ma...@yahoo.com> wrote:

> but in this document
> http://struts.apache.org/2.1.6/docs/iterator.html
> id attribute is deprecated.
>
> Louis
>
>
> ________________________________
> From: Chris Pratt <th...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wednesday, August 5, 2009 4:54:31 PM
> Subject: Re: struts2 ognl confusion
>
> You must be using a fairly old version of Struts 2.  The difference between
> the ${} and the # versions is that the ${} is a JSTL EL expression that is
> no longer allowed inside struts (s:) tags for security reasons.  The #
> version is OGNL and references the variable that Wes tried to define.  Try
> using the id attribute instead of the var attribute.  So something more
> like
> this:
>
> <s:iterator value="%{questions}" status="status" id="question">
>   <s:if test='%{incorrectQs.contains(#question.questionId)}'>
>        <div style="color: red; padding-bottom: 5px;">Print Something</div>
>    </s:if>
> </s:iterator>
>
> I like to make it obvious which attributes use OGNL by enclosing them in
> %{}
>  (*Chris*)
>
> On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
>
> > oh and attribute 'var' seems to be invalid according to the TLD
> >
> > On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
> > wrote:
> >
> > > ok thanks Wes. yeah that is def. more readable.
> > > could you please tell me what the difference is in doing
> > >     <s:if test='incorrectQs.contains("${questionId}")'>
> > > VS.
> > >     <s:if test='incorrectQs.contains(#question.questionId)'>
> > >
> > > beside the question.questionId part. I am more concerned about
> difference
> > > in '$' vs. '#'
> > >
> > >
> > > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> > wrote:
> > >
> > >> I think this would be more readable -
> > >>
> > >> <s:iterator value="questions" status="status" var="question">
> > >>    <s:if test='incorrectQs.contains(#question.questionId)'>
> > >>         <div style="color: red; padding-bottom: 5px;">Print
> > >> Something</div>
> > >>     </s:if>
> > >> </s:iterator>
> > >>
> > >> -Wes
> > >>
> > >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> > >> wrote:
> > >> > I have the following code in a jsp
> > >> > Line1: <s:iterator value="questions" status="status">
> > >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> > >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> > >> > Something</div>
> > >> > Line4:    </s:if>
> > >> > Line5:</s:iterator>
> > >> >
> > >> > On Line1 questions is a list.  This list contains object of class
> > Exam.
> > >> > Class Exam has a getter/setter questionId
> > >> > On Line2 incorrectQs is a list.  This list contains strings.
> > >> >
> > >> > I am checking to see if list in Line2 contains a questionId that is
> in
> > >> > questions list on line1.
> > >> >
> > >> > Is this the best way to do this?
> > >> >
> > >> > the code seems to be working but 'randomly' sometimes Line2 never
> > seems
> > >> to
> > >> > be true ...when we know it IS true.
> > >> >
> > >> > I just want to make sure with some experienced people whether this
> is
> > >> the
> > >> > way to achieve this?
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Wes Wannemacher
> > >>
> > >> Head Engineer, WanTii, Inc.
> > >> Need Training? Struts, Spring, Maven, Tomcat...
> > >> Ask me for a quote!
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> > >
> >
>

Re: struts2 ognl confusion

Posted by ma...@yahoo.com.
but in this document
http://struts.apache.org/2.1.6/docs/iterator.html
id attribute is deprecated.

Louis


________________________________
From: Chris Pratt <th...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, August 5, 2009 4:54:31 PM
Subject: Re: struts2 ognl confusion

You must be using a fairly old version of Struts 2.  The difference between
the ${} and the # versions is that the ${} is a JSTL EL expression that is
no longer allowed inside struts (s:) tags for security reasons.  The #
version is OGNL and references the variable that Wes tried to define.  Try
using the id attribute instead of the var attribute.  So something more like
this:

<s:iterator value="%{questions}" status="status" id="question">
   <s:if test='%{incorrectQs.contains(#question.questionId)}'>
        <div style="color: red; padding-bottom: 5px;">Print Something</div>
    </s:if>
</s:iterator>

I like to make it obvious which attributes use OGNL by enclosing them in %{}
  (*Chris*)

On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com> wrote:

> oh and attribute 'var' seems to be invalid according to the TLD
>
> On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
>
> > ok thanks Wes. yeah that is def. more readable.
> > could you please tell me what the difference is in doing
> >     <s:if test='incorrectQs.contains("${questionId}")'>
> > VS.
> >     <s:if test='incorrectQs.contains(#question.questionId)'>
> >
> > beside the question.questionId part. I am more concerned about difference
> > in '$' vs. '#'
> >
> >
> > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> wrote:
> >
> >> I think this would be more readable -
> >>
> >> <s:iterator value="questions" status="status" var="question">
> >>    <s:if test='incorrectQs.contains(#question.questionId)'>
> >>         <div style="color: red; padding-bottom: 5px;">Print
> >> Something</div>
> >>     </s:if>
> >> </s:iterator>
> >>
> >> -Wes
> >>
> >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> >> wrote:
> >> > I have the following code in a jsp
> >> > Line1: <s:iterator value="questions" status="status">
> >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> >> > Something</div>
> >> > Line4:    </s:if>
> >> > Line5:</s:iterator>
> >> >
> >> > On Line1 questions is a list.  This list contains object of class
> Exam.
> >> > Class Exam has a getter/setter questionId
> >> > On Line2 incorrectQs is a list.  This list contains strings.
> >> >
> >> > I am checking to see if list in Line2 contains a questionId that is in
> >> > questions list on line1.
> >> >
> >> > Is this the best way to do this?
> >> >
> >> > the code seems to be working but 'randomly' sometimes Line2 never
> seems
> >> to
> >> > be true ...when we know it IS true.
> >> >
> >> > I just want to make sure with some experienced people whether this is
> >> the
> >> > way to achieve this?
> >> >
> >>
> >>
> >>
> >> --
> >> Wes Wannemacher
> >>
> >> Head Engineer, WanTii, Inc.
> >> Need Training? Struts, Spring, Maven, Tomcat...
> >> Ask me for a quote!
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>

Re: struts2 ognl confusion

Posted by Chris Pratt <th...@gmail.com>.
You must be using a fairly old version of Struts 2.  The difference between
the ${} and the # versions is that the ${} is a JSTL EL expression that is
no longer allowed inside struts (s:) tags for security reasons.  The #
version is OGNL and references the variable that Wes tried to define.  Try
using the id attribute instead of the var attribute.  So something more like
this:

<s:iterator value="%{questions}" status="status" id="question">
   <s:if test='%{incorrectQs.contains(#question.questionId)}'>
        <div style="color: red; padding-bottom: 5px;">Print Something</div>
    </s:if>
</s:iterator>

I like to make it obvious which attributes use OGNL by enclosing them in %{}
  (*Chris*)

On Wed, Aug 5, 2009 at 8:43 AM, Bhaarat Sharma <bh...@gmail.com> wrote:

> oh and attribute 'var' seems to be invalid according to the TLD
>
> On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com>
> wrote:
>
> > ok thanks Wes. yeah that is def. more readable.
> > could you please tell me what the difference is in doing
> >     <s:if test='incorrectQs.contains("${questionId}")'>
> > VS.
> >     <s:if test='incorrectQs.contains(#question.questionId)'>
> >
> > beside the question.questionId part. I am more concerned about difference
> > in '$' vs. '#'
> >
> >
> > On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com>
> wrote:
> >
> >> I think this would be more readable -
> >>
> >> <s:iterator value="questions" status="status" var="question">
> >>    <s:if test='incorrectQs.contains(#question.questionId)'>
> >>         <div style="color: red; padding-bottom: 5px;">Print
> >> Something</div>
> >>     </s:if>
> >> </s:iterator>
> >>
> >> -Wes
> >>
> >> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> >> wrote:
> >> > I have the following code in a jsp
> >> > Line1: <s:iterator value="questions" status="status">
> >> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> >> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> >> > Something</div>
> >> > Line4:    </s:if>
> >> > Line5:</s:iterator>
> >> >
> >> > On Line1 questions is a list.  This list contains object of class
> Exam.
> >> > Class Exam has a getter/setter questionId
> >> > On Line2 incorrectQs is a list.  This list contains strings.
> >> >
> >> > I am checking to see if list in Line2 contains a questionId that is in
> >> > questions list on line1.
> >> >
> >> > Is this the best way to do this?
> >> >
> >> > the code seems to be working but 'randomly' sometimes Line2 never
> seems
> >> to
> >> > be true ...when we know it IS true.
> >> >
> >> > I just want to make sure with some experienced people whether this is
> >> the
> >> > way to achieve this?
> >> >
> >>
> >>
> >>
> >> --
> >> Wes Wannemacher
> >>
> >> Head Engineer, WanTii, Inc.
> >> Need Training? Struts, Spring, Maven, Tomcat...
> >> Ask me for a quote!
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>

Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
oh and attribute 'var' seems to be invalid according to the TLD

On Wed, Aug 5, 2009 at 11:42 AM, Bhaarat Sharma <bh...@gmail.com> wrote:

> ok thanks Wes. yeah that is def. more readable.
> could you please tell me what the difference is in doing
>     <s:if test='incorrectQs.contains("${questionId}")'>
> VS.
>     <s:if test='incorrectQs.contains(#question.questionId)'>
>
> beside the question.questionId part. I am more concerned about difference
> in '$' vs. '#'
>
>
> On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>> I think this would be more readable -
>>
>> <s:iterator value="questions" status="status" var="question">
>>    <s:if test='incorrectQs.contains(#question.questionId)'>
>>         <div style="color: red; padding-bottom: 5px;">Print
>> Something</div>
>>     </s:if>
>> </s:iterator>
>>
>> -Wes
>>
>> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
>> wrote:
>> > I have the following code in a jsp
>> > Line1: <s:iterator value="questions" status="status">
>> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
>> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
>> > Something</div>
>> > Line4:    </s:if>
>> > Line5:</s:iterator>
>> >
>> > On Line1 questions is a list.  This list contains object of class Exam.
>> > Class Exam has a getter/setter questionId
>> > On Line2 incorrectQs is a list.  This list contains strings.
>> >
>> > I am checking to see if list in Line2 contains a questionId that is in
>> > questions list on line1.
>> >
>> > Is this the best way to do this?
>> >
>> > the code seems to be working but 'randomly' sometimes Line2 never seems
>> to
>> > be true ...when we know it IS true.
>> >
>> > I just want to make sure with some experienced people whether this is
>> the
>> > way to achieve this?
>> >
>>
>>
>>
>> --
>> Wes Wannemacher
>>
>> Head Engineer, WanTii, Inc.
>> Need Training? Struts, Spring, Maven, Tomcat...
>> Ask me for a quote!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

Re: struts2 ognl confusion

Posted by Bhaarat Sharma <bh...@gmail.com>.
ok thanks Wes. yeah that is def. more readable.
could you please tell me what the difference is in doing
    <s:if test='incorrectQs.contains("${questionId}")'>
VS.
    <s:if test='incorrectQs.contains(#question.questionId)'>

beside the question.questionId part. I am more concerned about difference in
'$' vs. '#'

On Wed, Aug 5, 2009 at 11:39 AM, Wes Wannemacher <we...@wantii.com> wrote:

> I think this would be more readable -
>
> <s:iterator value="questions" status="status" var="question">
>    <s:if test='incorrectQs.contains(#question.questionId)'>
>         <div style="color: red; padding-bottom: 5px;">Print Something</div>
>     </s:if>
> </s:iterator>
>
> -Wes
>
> On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com>
> wrote:
> > I have the following code in a jsp
> > Line1: <s:iterator value="questions" status="status">
> > Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> > Line3:        <div style="color: red; padding-bottom: 5px;">Print
> > Something</div>
> > Line4:    </s:if>
> > Line5:</s:iterator>
> >
> > On Line1 questions is a list.  This list contains object of class Exam.
> > Class Exam has a getter/setter questionId
> > On Line2 incorrectQs is a list.  This list contains strings.
> >
> > I am checking to see if list in Line2 contains a questionId that is in
> > questions list on line1.
> >
> > Is this the best way to do this?
> >
> > the code seems to be working but 'randomly' sometimes Line2 never seems
> to
> > be true ...when we know it IS true.
> >
> > I just want to make sure with some experienced people whether this is the
> > way to achieve this?
> >
>
>
>
> --
> Wes Wannemacher
>
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: struts2 ognl confusion

Posted by Wes Wannemacher <we...@wantii.com>.
I think this would be more readable -

<s:iterator value="questions" status="status" var="question">
    <s:if test='incorrectQs.contains(#question.questionId)'>
        <div style="color: red; padding-bottom: 5px;">Print Something</div>
    </s:if>
</s:iterator>

-Wes

On Wed, Aug 5, 2009 at 11:35 AM, Bhaarat Sharma<bh...@gmail.com> wrote:
> I have the following code in a jsp
> Line1: <s:iterator value="questions" status="status">
> Line2:    <s:if test='incorrectQs.contains("${questionId}")'>
> Line3:        <div style="color: red; padding-bottom: 5px;">Print
> Something</div>
> Line4:    </s:if>
> Line5:</s:iterator>
>
> On Line1 questions is a list.  This list contains object of class Exam.
> Class Exam has a getter/setter questionId
> On Line2 incorrectQs is a list.  This list contains strings.
>
> I am checking to see if list in Line2 contains a questionId that is in
> questions list on line1.
>
> Is this the best way to do this?
>
> the code seems to be working but 'randomly' sometimes Line2 never seems to
> be true ...when we know it IS true.
>
> I just want to make sure with some experienced people whether this is the
> way to achieve this?
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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