You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Othon Reyes Sanchez <ot...@gmail.com> on 2008/07/12 03:50:04 UTC

Problem with s:set and s:if

Hi to everyone

I have a problem with the following code:

<s:set name="aver" scope="page" value="one"></s:set
...
<s:if test="#page.aver=='one'">
<%-- Some code goes here --%>
</s:if>

I don't know what is happening but the code conditionated by the if is not
executed.
If i use request instead of page in the s:set tag, and obiosly in the s:if
tag, the code works fine.

can somebody tell me what i'm doing wrong?

Re: Problem with s:set and s:if

Posted by Othon Reyes Sanchez <ot...@gmail.com>.
thanks!!!. that solved my problem

On Sat, Jul 12, 2008 at 12:23 PM, Gabriel Belingueres <be...@gmail.com>
wrote:

> Looking at the docs:
> http://struts.apache.org/2.1.2/docs/ognl.html
>
> there is no #page notation when using struts taglibs, since they all
> use OGNL syntax.
> If you need to access a page scoped object, you need to use the #attr
> notation.
>
> 2008/7/12 Othon Reyes Sanchez <ot...@gmail.com>:
>  > #page is not an instance of a user class.
> > page is an implicit object of jsp like request, session, application,
> etc.
> >
> > i don't know what is happening if i use <s:set name="aver" scope="page"
> > value="one"></s:set>
> > to put the variable "aver" in the page object it works fine. i mean, i
> can
> > use EL to use this var i.e. ( ${pageScope.aver} ).
> >
> > I think that my problem is that i don't know is how Io refer to the
> variable
> > aver that "lives" in the page implicit object.
> > I suppose there should be a way to do this, and i'm supposing this
> because
> > JSTL lets you do it like the following code:
> >
> > <c:if test="${pageScope.aver=='one'} ">
> > </c:if>
> >
> > i know S2 and JSTL is not the same but i think that this funcionality is
> > basic and S2 should allow you, unless there is a reason to not put a
> > instance in the page implicit object, but that doesn't have any sense.
> why
> > does S2 works with request or session but not with page?.
> >
> > Did i made myself clear?.
> >
> > BTW thanks for your help Dave.
> >
> >
> >
> > On Fri, Jul 11, 2008 at 10:07 PM, Dave Newton <ne...@yahoo.com>
> wrote:
> >
> >> Is #page one of the stack context vars? I'd consider using #attr, unless
> >> you can confirm that it is (I always forget). Or just use #request.
> >>
> >> Dave
> >>
> >> --- On Fri, 7/11/08, Othon Reyes Sanchez <ot...@gmail.com> wrote:
> >> > I have a problem with the following code:
> >> >
> >> > <s:set name="aver" scope="page"
> >> > value="one"></s:set
> >> > ...
> >> > <s:if test="#page.aver=='one'">
> >> > <%-- Some code goes here --%>
> >> > </s:if>
> >> >
> >> > I don't know what is happening but the code
> >> > conditionated by the if is not
> >> > executed.
> >> > If i use request instead of page in the s:set tag, and
> >> > obiosly in the s:if
> >> > tag, the code works fine.
> >> >
> >> > can somebody tell me what i'm doing wrong?
> >>
> >> ---------------------------------------------------------------------
> >> 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: Problem with s:set and s:if

Posted by Gabriel Belingueres <be...@gmail.com>.
Looking at the docs:
http://struts.apache.org/2.1.2/docs/ognl.html

there is no #page notation when using struts taglibs, since they all
use OGNL syntax.
If you need to access a page scoped object, you need to use the #attr notation.

2008/7/12 Othon Reyes Sanchez <ot...@gmail.com>:
> #page is not an instance of a user class.
> page is an implicit object of jsp like request, session, application, etc.
>
> i don't know what is happening if i use <s:set name="aver" scope="page"
> value="one"></s:set>
> to put the variable "aver" in the page object it works fine. i mean, i can
> use EL to use this var i.e. ( ${pageScope.aver} ).
>
> I think that my problem is that i don't know is how Io refer to the variable
> aver that "lives" in the page implicit object.
> I suppose there should be a way to do this, and i'm supposing this because
> JSTL lets you do it like the following code:
>
> <c:if test="${pageScope.aver=='one'} ">
> </c:if>
>
> i know S2 and JSTL is not the same but i think that this funcionality is
> basic and S2 should allow you, unless there is a reason to not put a
> instance in the page implicit object, but that doesn't have any sense. why
> does S2 works with request or session but not with page?.
>
> Did i made myself clear?.
>
> BTW thanks for your help Dave.
>
>
>
> On Fri, Jul 11, 2008 at 10:07 PM, Dave Newton <ne...@yahoo.com> wrote:
>
>> Is #page one of the stack context vars? I'd consider using #attr, unless
>> you can confirm that it is (I always forget). Or just use #request.
>>
>> Dave
>>
>> --- On Fri, 7/11/08, Othon Reyes Sanchez <ot...@gmail.com> wrote:
>> > I have a problem with the following code:
>> >
>> > <s:set name="aver" scope="page"
>> > value="one"></s:set
>> > ...
>> > <s:if test="#page.aver=='one'">
>> > <%-- Some code goes here --%>
>> > </s:if>
>> >
>> > I don't know what is happening but the code
>> > conditionated by the if is not
>> > executed.
>> > If i use request instead of page in the s:set tag, and
>> > obiosly in the s:if
>> > tag, the code works fine.
>> >
>> > can somebody tell me what i'm doing wrong?
>>
>> ---------------------------------------------------------------------
>> 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: Problem with s:set and s:if

Posted by Othon Reyes Sanchez <ot...@gmail.com>.
#page is not an instance of a user class.
page is an implicit object of jsp like request, session, application, etc.

i don't know what is happening if i use <s:set name="aver" scope="page"
value="one"></s:set>
to put the variable "aver" in the page object it works fine. i mean, i can
use EL to use this var i.e. ( ${pageScope.aver} ).

I think that my problem is that i don't know is how Io refer to the variable
aver that "lives" in the page implicit object.
I suppose there should be a way to do this, and i'm supposing this because
JSTL lets you do it like the following code:

<c:if test="${pageScope.aver=='one'} ">
</c:if>

i know S2 and JSTL is not the same but i think that this funcionality is
basic and S2 should allow you, unless there is a reason to not put a
instance in the page implicit object, but that doesn't have any sense. why
does S2 works with request or session but not with page?.

Did i made myself clear?.

BTW thanks for your help Dave.



On Fri, Jul 11, 2008 at 10:07 PM, Dave Newton <ne...@yahoo.com> wrote:

> Is #page one of the stack context vars? I'd consider using #attr, unless
> you can confirm that it is (I always forget). Or just use #request.
>
> Dave
>
> --- On Fri, 7/11/08, Othon Reyes Sanchez <ot...@gmail.com> wrote:
> > I have a problem with the following code:
> >
> > <s:set name="aver" scope="page"
> > value="one"></s:set
> > ...
> > <s:if test="#page.aver=='one'">
> > <%-- Some code goes here --%>
> > </s:if>
> >
> > I don't know what is happening but the code
> > conditionated by the if is not
> > executed.
> > If i use request instead of page in the s:set tag, and
> > obiosly in the s:if
> > tag, the code works fine.
> >
> > can somebody tell me what i'm doing wrong?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Problem with s:set and s:if

Posted by Dave Newton <ne...@yahoo.com>.
Is #page one of the stack context vars? I'd consider using #attr, unless you can confirm that it is (I always forget). Or just use #request.

Dave

--- On Fri, 7/11/08, Othon Reyes Sanchez <ot...@gmail.com> wrote:
> I have a problem with the following code:
> 
> <s:set name="aver" scope="page"
> value="one"></s:set
> ...
> <s:if test="#page.aver=='one'">
> <%-- Some code goes here --%>
> </s:if>
> 
> I don't know what is happening but the code
> conditionated by the if is not
> executed.
> If i use request instead of page in the s:set tag, and
> obiosly in the s:if
> tag, the code works fine.
> 
> can somebody tell me what i'm doing wrong?

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