You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mansour <ma...@yahoo.com> on 2007/05/16 03:59:44 UTC

Action View wiring

I have this little problem. Basically I am trying to iterate through a 
list and dispaly the results in a column using tableTag:

<tt:table value="accountsList">
    <tt:column title="Account Name">
        <s:form action="getAccountById">
            <s:hidden name="id" />
                <s:a onclick="parentNode.submit();" href="javascript://">
                <s:property value="firstName" />
                <s:property value="lastName" />
            </s:a>
        </s:form>
    </tt:column>

This is giving me the expected results and things are ok. When I click 
the link it sets the "id" in teh next action. However, I don't want to 
use set id. I need to set an Account Id like this

            <s:hidden name="acc.id" />

but then if I do this, it will never obtain the id from the list I am 
iterating over.
Any idea?


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


Re: Action View wiring

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> For a moment I thought I am the only one struggling
> with this. 

I'm pretty sure you're not! It gave me nothing but
grief for a few weeks, and I still get a little
confused sometimes.

One of the issues is that the tag library docs don't
specify which tag attributes are expecting OGNL
expressions and which aren't. Digging in the source is
actually the quickest way to figure some stuff out for
now, and has other benefits as well :)

> Thank you for the clarification. Do you know any 
> tutorial with examples ?

Honestly, *everything* I know about OGNL came from the
following three links:

http://struts.apache.org/2.x/docs/ognl.html
http://struts.apache.org/2.x/docs/ognl-basics.html
http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html

I also spent a few hours just playing around with OGNL
EL expressions, trying out the stuff from the OGNL
language guide, etc. That proved to be the most
beneficial, and there are a lot of neat little OGNL
tricks that are very handy sometimes from that guide,
in particular:

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/specialCollectionsProperties.html

and

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/projection.html

which, if followed to its logical conclusion, gives
you a fair amount of power in selecting items from an
existing list without having to write any Java code.

d.



       
____________________________________________________________________________________Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

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


Re: Action View wiring

Posted by Mansour <ma...@yahoo.com>.
Dave:
For a moment I thought I am the only one struggling with this. Thank you 
for the clarification. Do you know any tutorial with examples ?


Dave Newton wrote:
> --- Roger Varley <ro...@googlemail.com> wrote:
>   
>> Is there any clear documentation that will explain
>> when you need to use '%', '$' or '#' in Struts2 
>>     
> .jsp
>   
>> pages as I'm finding it all very confusing.
>>     
>
> I thought there was, but I can't access it at the
> moment.
>
> In a nutshell, if you use ${} you're using JSP EL. S2
> wraps things up so if what you're trying to access
> isn't in scope it will get passed on to the OGNL value
> stack.
>
> %{} is OGNL EL and is often optional depending on what
> attribute you're using... this is the most confusing
> part AFAIC.
>
> # is used for accessing non-root OGNL objects, like an
> iterator-defined variable, etc.
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> Now that's room service!  Choose from over 150,000 hotels
> in 45,000 destinations on Yahoo! Travel to find your fit.
> http://farechase.yahoo.com/promo-generic-14795097
>
> ---------------------------------------------------------------------
> 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: Action View wiring

Posted by Dave Newton <ne...@yahoo.com>.
--- Roger Varley <ro...@googlemail.com> wrote:
> Is there any clear documentation that will explain
> when you need to use '%', '$' or '#' in Struts2 
.jsp
> pages as I'm finding it all very confusing.

I thought there was, but I can't access it at the
moment.

In a nutshell, if you use ${} you're using JSP EL. S2
wraps things up so if what you're trying to access
isn't in scope it will get passed on to the OGNL value
stack.

%{} is OGNL EL and is often optional depending on what
attribute you're using... this is the most confusing
part AFAIC.

# is used for accessing non-root OGNL objects, like an
iterator-defined variable, etc.

d.



 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097

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


Re: Action View wiring

Posted by Roger Varley <ro...@googlemail.com>.
On 16/05/07, Mansour <ma...@yahoo.com> wrote:
> Mansour wrote:
> I found it. I'll post it just in case someone needs it. I used "%{id}"
> instead of "${id}" and EL expression is evaluated immediately on the
> first load. I don't know why. I 'd love to hear explanation form
> someone. But it's working after all.
>

Is there any clear documentation that will explain when you need to
use '%', '$' or '#' in Struts2  .jsp pages as I'm finding it all very
confusing.

Regards
Roger

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


Re: Action View wiring

Posted by Mansour <ma...@yahoo.com>.
Mansour wrote:
I found it. I'll post it just in case someone needs it. I used "%{id}" 
instead of "${id}" and EL expression is evaluated immediately on the 
first load. I don't know why. I 'd love to hear explanation form 
someone. But it's working after all.

<s:hidden name="acc.id" value="%{id}" />

> OK I am closer. I just put this:
>
> <s:hidden name="acc.id" value="${id}" />
>
> But, it works only sometimes. I notices that the values are set in the 
> html only after I refresh the page !
> Any one knows what going on ??
>
>
>
>
> Mansour wrote:
>> I have this little problem. Basically I am trying to iterate through 
>> a list and dispaly the results in a column using tableTag:
>>
>> <tt:table value="accountsList">
>>    <tt:column title="Account Name">
>>        <s:form action="getAccountById">
>>            <s:hidden name="id" />
>>                <s:a onclick="parentNode.submit();" href="javascript://">
>>                <s:property value="firstName" />
>>                <s:property value="lastName" />
>>            </s:a>
>>        </s:form>
>>    </tt:column>
>>
>> This is giving me the expected results and things are ok. When I 
>> click the link it sets the "id" in teh next action. However, I don't 
>> want to use set id. I need to set an Account Id like this
>>
>>            <s:hidden name="acc.id" />
>>
>> but then if I do this, it will never obtain the id from the list I am 
>> iterating over.
>> Any idea?
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>


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


Re: Action View wiring

Posted by Mansour <ma...@yahoo.com>.
OK I am closer. I just put this:

<s:hidden name="acc.id" value="${id}" />

But, it works only sometimes. I notices that the values are set in the 
html only after I refresh the page !
Any one knows what going on ??




Mansour wrote:
> I have this little problem. Basically I am trying to iterate through a 
> list and dispaly the results in a column using tableTag:
>
> <tt:table value="accountsList">
>    <tt:column title="Account Name">
>        <s:form action="getAccountById">
>            <s:hidden name="id" />
>                <s:a onclick="parentNode.submit();" href="javascript://">
>                <s:property value="firstName" />
>                <s:property value="lastName" />
>            </s:a>
>        </s:form>
>    </tt:column>
>
> This is giving me the expected results and things are ok. When I click 
> the link it sets the "id" in teh next action. However, I don't want to 
> use set id. I need to set an Account Id like this
>
>            <s:hidden name="acc.id" />
>
> but then if I do this, it will never obtain the id from the list I am 
> iterating over.
> Any idea?
>
>
> ---------------------------------------------------------------------
> 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