You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Felipe Rodrigues <fe...@yahoo.com.br> on 2007/05/08 21:31:56 UTC

OGNL question

Hi,

How could i do that 

<s:url id="setUsina${id}" action="UpdateHome!selectPlant">
      </s:url>
      <s:a id="any" 
        name="any" 
        href="%{setUsina${id}}"  theme="ajax">Link</s:a>

changing EL by OGNL?
The especific part  href="%{setUsina${id}}" . I tried 
href="%{setUsina(#id)}" but didn't work.

Thanks,


Felipe


-- 
View this message in context: http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
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: OGNL question

Posted by Laurie Harper <la...@holoweb.net>.
Felipe Rodrigues wrote:
> I'm sorry about don't provide all the informations. I'll try to explain a
> little more.
> 
> I'm trying to generate a <s:a>  tag for each item in a list, but I have to
> send a param when click on this <s:a> link.
> This is why I use <s:url> to do that. My code seems like that:
> 
>   <s:iterator value="type">
>     <tr>
>       <td>
>         <s:url id="url%{id}" action="Variables">
>            <s:param name="typeId" value="id"></s:param>
>         </s:url>

Again, why do you need to make the id attribute on the s:url tag 
dynamic? Just use <s:url id="url" ... as I suggested in a previous post.

>         <s:a id="tipo${module}%{id}" 
>           name="tipo${module}%{id}" 
>           href="%{url}" <!-- Here is my problem. I need lots of url, but not
> with the same id, because my param changes
>                                         according to the type I'm itereting
> -->

You have href="%{url}" but used id="url%{id}" in the s:url tag above. 
Fix the s:url tag, and this should work fine. The id attribute on the 
s:a tag *does* need to be unique, since it becomes part of the rendered 
HTML. The id attribute on the s:url tag doesn't, but the s:a's href 
attribute must sync up with the s:url's id attribute.

>           cssClass="listItem" 
>           notifyTopics="changeTypeListItem" 
>           theme="ajax"  
>           showLoadingText="false"><s:property value="dsc"/></s:a>
>       </td>
>     </tr>
>   </s:iterator>
> 
> I was doing this with <c:forEach>, but some changes in my project made me
> change from <c:forEach> to <s:iterator>. When using forEach I could just use
> EL, but with iterator, I can't (I think I can't, but not sure).
> How could I do that in this case?

You should be able to get this working using either s:iterator or 
c:forEach. Try the suggestion above and, if you still have problems, 
post the errors you get and/or the incorrect markup that's produced.

L.

> Thanks in advance,
> 
> Felipe
> 
> 
> Laurie Harper wrote:
>> Why do you need to make the url-id unique on each loop iteration? Have 
>> you tried simply writing something like
>>
>>    <c:forEach ...>
>>      <s:url id="url" .../>
>>      <s:a href="%{#id}" .../>
>>      ...
>>
>> You should, on the other hand, provide a unique value for the 'id' (and 
>> possibly 'name) attribute on the s:a tag as those get passed through to 
>> the rendered HTML.
>>
>> If you're still having trouble, try describing what exactly you are 
>> trying to achieve, and posting a more complete code sample of how you're 
>> trying to achieve it.
>>
>> L.
>>
>> Felipe Rodrigues wrote:
>>> I'm sorry, but I didn't got it.
>>> When I pass in a parameter, I'll send it to the destiny. That is not what
>>> I
>>> want. I only want to identify the url according to the id. This code is
>>> inside a foreach, that renders lots of urls.
>>>
>>> How would be that in this case?
>>>
>>> Thanks,
>>>
>>> Felipe
>>>
>>>
>>> Martin Gainty wrote:
>>>> You'll need to pass in a parameter for id such as this
>>>> <s:url value="UpdateHome.selectPlant">
>>>>     <s:param name="id" value="%{id}" />
>>>> </s:url>
>>>>
>>>> M--
>>>> This email message and any files transmitted with it contain
>>>> confidential
>>>> information intended only for the person(s) to whom this email message
>>>> is
>>>> addressed.  If you have received this email message in error, please
>>>> notify
>>>> the sender immediately by telephone or email and destroy the original
>>>> message without making a copy.  Thank you.
>>>>
>>>> ----- Original Message ----- 
>>>> From: "Felipe Rodrigues" <fe...@yahoo.com.br>
>>>> To: <us...@struts.apache.org>
>>>> Sent: Tuesday, May 08, 2007 3:31 PM
>>>> Subject: OGNL question
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> How could i do that
>>>>>
>>>>> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>>>>>      </s:url>
>>>>>      <s:a id="any"
>>>>>        name="any"
>>>>>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>>>>>
>>>>> changing EL by OGNL?
>>>>> The especific part  href="%{setUsina${id}}" . I tried
>>>>> href="%{setUsina(#id)}" but didn't work.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>>> Felipe
>>>>>
>>>>>
>>>>> -- 
>>>>> View this message in context: 
>>>>> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
>>>>> 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
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: OGNL question

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
I got it using <c:forEach> again. I didn't realize that I can use EL to get
values from some Action as well.
But I keep wondering if I can't do that by using <s:iterator> and OGNL.

Thanks,

Felipe



Felipe Rodrigues wrote:
> 
> I'm sorry about don't provide all the informations. I'll try to explain a
> little more.
> 
> I'm trying to generate a <s:a>  tag for each item in a list, but I have to
> send a param when click on this <s:a> link.
> This is why I use <s:url> to do that. My code seems like that:
> 
>   <s:iterator value="type">
>     <tr>
>       <td>
>         <s:url id="url%{id}" action="Variables">
>            <s:param name="typeId" value="id"></s:param>
>         </s:url>
>         <s:a id="tipo${module}%{id}" 
>           name="tipo${module}%{id}" 
>           href="%{url}" <!-- Here is my problem. I need lots of url, but
> not with the same id, because my param changes
>                                         according to the type I'm
> itereting -->
>           cssClass="listItem" 
>           notifyTopics="changeTypeListItem" 
>           theme="ajax"  
>           showLoadingText="false"><s:property value="dsc"/></s:a>
>       </td>
>     </tr>
>   </s:iterator>
> 
> I was doing this with <c:forEach>, but some changes in my project made me
> change from <c:forEach> to <s:iterator>. When using forEach I could just
> use EL, but with iterator, I can't (I think I can't, but not sure).
> How could I do that in this case?
> 
> Thanks in advance,
> 
> Felipe
> 
> 
> Laurie Harper wrote:
>> 
>> Why do you need to make the url-id unique on each loop iteration? Have 
>> you tried simply writing something like
>> 
>>    <c:forEach ...>
>>      <s:url id="url" .../>
>>      <s:a href="%{#id}" .../>
>>      ...
>> 
>> You should, on the other hand, provide a unique value for the 'id' (and 
>> possibly 'name) attribute on the s:a tag as those get passed through to 
>> the rendered HTML.
>> 
>> If you're still having trouble, try describing what exactly you are 
>> trying to achieve, and posting a more complete code sample of how you're 
>> trying to achieve it.
>> 
>> L.
>> 
>> Felipe Rodrigues wrote:
>>> I'm sorry, but I didn't got it.
>>> When I pass in a parameter, I'll send it to the destiny. That is not
>>> what I
>>> want. I only want to identify the url according to the id. This code is
>>> inside a foreach, that renders lots of urls.
>>> 
>>> How would be that in this case?
>>> 
>>> Thanks,
>>> 
>>> Felipe
>>> 
>>> 
>>> Martin Gainty wrote:
>>>> You'll need to pass in a parameter for id such as this
>>>> <s:url value="UpdateHome.selectPlant">
>>>>     <s:param name="id" value="%{id}" />
>>>> </s:url>
>>>>
>>>> M--
>>>> This email message and any files transmitted with it contain
>>>> confidential
>>>> information intended only for the person(s) to whom this email message
>>>> is
>>>> addressed.  If you have received this email message in error, please
>>>> notify
>>>> the sender immediately by telephone or email and destroy the original
>>>> message without making a copy.  Thank you.
>>>>
>>>> ----- Original Message ----- 
>>>> From: "Felipe Rodrigues" <fe...@yahoo.com.br>
>>>> To: <us...@struts.apache.org>
>>>> Sent: Tuesday, May 08, 2007 3:31 PM
>>>> Subject: OGNL question
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> How could i do that
>>>>>
>>>>> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>>>>>      </s:url>
>>>>>      <s:a id="any"
>>>>>        name="any"
>>>>>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>>>>>
>>>>> changing EL by OGNL?
>>>>> The especific part  href="%{setUsina${id}}" . I tried
>>>>> href="%{setUsina(#id)}" but didn't work.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>>> Felipe
>>>>>
>>>>>
>>>>> -- 
>>>>> View this message in context: 
>>>>> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
>>>>> 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
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/OGNL-question-tf3711762.html#a10403571
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: OGNL question

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
I'm sorry about don't provide all the informations. I'll try to explain a
little more.

I'm trying to generate a <s:a>  tag for each item in a list, but I have to
send a param when click on this <s:a> link.
This is why I use <s:url> to do that. My code seems like that:

  <s:iterator value="type">
    <tr>
      <td>
        <s:url id="url%{id}" action="Variables">
           <s:param name="typeId" value="id"></s:param>
        </s:url>
        <s:a id="tipo${module}%{id}" 
          name="tipo${module}%{id}" 
          href="%{url}" <!-- Here is my problem. I need lots of url, but not
with the same id, because my param changes
                                        according to the type I'm itereting
-->
          cssClass="listItem" 
          notifyTopics="changeTypeListItem" 
          theme="ajax"  
          showLoadingText="false"><s:property value="dsc"/></s:a>
      </td>
    </tr>
  </s:iterator>

I was doing this with <c:forEach>, but some changes in my project made me
change from <c:forEach> to <s:iterator>. When using forEach I could just use
EL, but with iterator, I can't (I think I can't, but not sure).
How could I do that in this case?

Thanks in advance,

Felipe


Laurie Harper wrote:
> 
> Why do you need to make the url-id unique on each loop iteration? Have 
> you tried simply writing something like
> 
>    <c:forEach ...>
>      <s:url id="url" .../>
>      <s:a href="%{#id}" .../>
>      ...
> 
> You should, on the other hand, provide a unique value for the 'id' (and 
> possibly 'name) attribute on the s:a tag as those get passed through to 
> the rendered HTML.
> 
> If you're still having trouble, try describing what exactly you are 
> trying to achieve, and posting a more complete code sample of how you're 
> trying to achieve it.
> 
> L.
> 
> Felipe Rodrigues wrote:
>> I'm sorry, but I didn't got it.
>> When I pass in a parameter, I'll send it to the destiny. That is not what
>> I
>> want. I only want to identify the url according to the id. This code is
>> inside a foreach, that renders lots of urls.
>> 
>> How would be that in this case?
>> 
>> Thanks,
>> 
>> Felipe
>> 
>> 
>> Martin Gainty wrote:
>>> You'll need to pass in a parameter for id such as this
>>> <s:url value="UpdateHome.selectPlant">
>>>     <s:param name="id" value="%{id}" />
>>> </s:url>
>>>
>>> M--
>>> This email message and any files transmitted with it contain
>>> confidential
>>> information intended only for the person(s) to whom this email message
>>> is
>>> addressed.  If you have received this email message in error, please
>>> notify
>>> the sender immediately by telephone or email and destroy the original
>>> message without making a copy.  Thank you.
>>>
>>> ----- Original Message ----- 
>>> From: "Felipe Rodrigues" <fe...@yahoo.com.br>
>>> To: <us...@struts.apache.org>
>>> Sent: Tuesday, May 08, 2007 3:31 PM
>>> Subject: OGNL question
>>>
>>>
>>>> Hi,
>>>>
>>>> How could i do that
>>>>
>>>> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>>>>      </s:url>
>>>>      <s:a id="any"
>>>>        name="any"
>>>>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>>>>
>>>> changing EL by OGNL?
>>>> The especific part  href="%{setUsina${id}}" . I tried
>>>> href="%{setUsina(#id)}" but didn't work.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> Felipe
>>>>
>>>>
>>>> -- 
>>>> View this message in context: 
>>>> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
>>>> 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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/OGNL-question-tf3711762.html#a10393352
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: OGNL question

Posted by Laurie Harper <la...@holoweb.net>.
Why do you need to make the url-id unique on each loop iteration? Have 
you tried simply writing something like

   <c:forEach ...>
     <s:url id="url" .../>
     <s:a href="%{#id}" .../>
     ...

You should, on the other hand, provide a unique value for the 'id' (and 
possibly 'name) attribute on the s:a tag as those get passed through to 
the rendered HTML.

If you're still having trouble, try describing what exactly you are 
trying to achieve, and posting a more complete code sample of how you're 
trying to achieve it.

L.

Felipe Rodrigues wrote:
> I'm sorry, but I didn't got it.
> When I pass in a parameter, I'll send it to the destiny. That is not what I
> want. I only want to identify the url according to the id. This code is
> inside a foreach, that renders lots of urls.
> 
> How would be that in this case?
> 
> Thanks,
> 
> Felipe
> 
> 
> Martin Gainty wrote:
>> You'll need to pass in a parameter for id such as this
>> <s:url value="UpdateHome.selectPlant">
>>     <s:param name="id" value="%{id}" />
>> </s:url>
>>
>> M--
>> This email message and any files transmitted with it contain confidential
>> information intended only for the person(s) to whom this email message is
>> addressed.  If you have received this email message in error, please
>> notify
>> the sender immediately by telephone or email and destroy the original
>> message without making a copy.  Thank you.
>>
>> ----- Original Message ----- 
>> From: "Felipe Rodrigues" <fe...@yahoo.com.br>
>> To: <us...@struts.apache.org>
>> Sent: Tuesday, May 08, 2007 3:31 PM
>> Subject: OGNL question
>>
>>
>>> Hi,
>>>
>>> How could i do that
>>>
>>> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>>>      </s:url>
>>>      <s:a id="any"
>>>        name="any"
>>>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>>>
>>> changing EL by OGNL?
>>> The especific part  href="%{setUsina${id}}" . I tried
>>> href="%{setUsina(#id)}" but didn't work.
>>>
>>> Thanks,
>>>
>>>
>>> Felipe
>>>
>>>
>>> -- 
>>> View this message in context: 
>>> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
>>> 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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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: OGNL question

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
I'm sorry, but I didn't got it.
When I pass in a parameter, I'll send it to the destiny. That is not what I
want. I only want to identify the url according to the id. This code is
inside a foreach, that renders lots of urls.

How would be that in this case?

Thanks,

Felipe


Martin Gainty wrote:
> 
> You'll need to pass in a parameter for id such as this
> <s:url value="UpdateHome.selectPlant">
>     <s:param name="id" value="%{id}" />
> </s:url>
> 
> M--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
> 
> ----- Original Message ----- 
> From: "Felipe Rodrigues" <fe...@yahoo.com.br>
> To: <us...@struts.apache.org>
> Sent: Tuesday, May 08, 2007 3:31 PM
> Subject: OGNL question
> 
> 
>>
>> Hi,
>>
>> How could i do that
>>
>> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>>      </s:url>
>>      <s:a id="any"
>>        name="any"
>>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>>
>> changing EL by OGNL?
>> The especific part  href="%{setUsina${id}}" . I tried
>> href="%{setUsina(#id)}" but didn't work.
>>
>> Thanks,
>>
>>
>> Felipe
>>
>>
>> -- 
>> View this message in context: 
>> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
>> 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
>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/OGNL-question-tf3711762.html#a10384600
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: OGNL question

Posted by Martin Gainty <mg...@hotmail.com>.
You'll need to pass in a parameter for id such as this
<s:url value="UpdateHome.selectPlant">
    <s:param name="id" value="%{id}" />
</s:url>

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Felipe Rodrigues" <fe...@yahoo.com.br>
To: <us...@struts.apache.org>
Sent: Tuesday, May 08, 2007 3:31 PM
Subject: OGNL question


>
> Hi,
>
> How could i do that
>
> <s:url id="setUsina${id}" action="UpdateHome!selectPlant">
>      </s:url>
>      <s:a id="any"
>        name="any"
>        href="%{setUsina${id}}"  theme="ajax">Link</s:a>
>
> changing EL by OGNL?
> The especific part  href="%{setUsina${id}}" . I tried
> href="%{setUsina(#id)}" but didn't work.
>
> Thanks,
>
>
> Felipe
>
>
> -- 
> View this message in context: 
> http://www.nabble.com/OGNL-question-tf3711762.html#a10382481
> 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
>
> 


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


Re: OGNL question

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
Sure, 
you can find it at 
http://struts.apache.org/2.x/docs/home.html


bigtdps2004 wrote:
> 
> Dopes anyone know where there is a good beginners tutorial on
> developing their first struts application even if I am using
> Eclipse, Ant and MySql ?
> 
> Thank you
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/OGNL-question-tf3711762.html#a10396879
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