You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Koenig <sc...@gmail.com> on 2011/05/10 17:44:27 UTC

string concatenation within an EL conditional

Hello,

This may fall under nested EL expressions, which to my understanding are
intentionally disallowed, but I was wondering if there was EL syntax that
would support what I am trying to do, namely, set a URL based on a
conditional, or if I should stick with <s:if>.

Currently I have

<s:if test="mn == #m.name">
    <a href="#landing">${m.dispName}</a>
</s:if>
<s:else>
    <a href="/internal!m?cName=${cName}&mName=${m.name}">${m.dispName}</a>
</s:else>

but would like to do it in a single line, something like

<a href="${mn == m.name ? '#landing' : '/internal!m?cName=' + cName +
'&mName=' + m.name}">${m.dispName}</a>

Is this possible?

Thanks,
~~Scott

Re: string concatenation within an EL conditional

Posted by Maurizio Cucchiara <ma...@gmail.com>.
I don't know if it works and/or it what you're looking for, but it
worths at least a try:

<s:a action="internal" namespace="/">
  <s:if test="mn != #m.name">
     <s:param name="cName" value="${cName}"/>
  </s:if>
${m.dispName}
</s:a>

Please let me know if it works.

On 10 May 2011 17:44, Scott Koenig <sc...@gmail.com> wrote:
> Hello,
>
> This may fall under nested EL expressions, which to my understanding are
> intentionally disallowed, but I was wondering if there was EL syntax that
> would support what I am trying to do, namely, set a URL based on a
> conditional, or if I should stick with <s:if>.
>
> Currently I have
>
> <s:if test="mn == #m.name">
>    <a href="#landing">${m.dispName}</a>
> </s:if>
> <s:else>
>    <a href="/internal!m?cName=${cName}&mName=${m.name}">${m.dispName}</a>
> </s:else>
>
> but would like to do it in a single line, something like
>
> <a href="${mn == m.name ? '#landing' : '/internal!m?cName=' + cName +
> '&mName=' + m.name}">${m.dispName}</a>
>
> Is this possible?
>
> Thanks,
> ~~Scott
>



-- 
Maurizio Cucchiara

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


Re: string concatenation within an EL conditional

Posted by Dave Newton <da...@gmail.com>.
On Tue, May 10, 2011 at 11:44 AM, Scott Koenig wrote:
> This may fall under nested EL expressions, which to my understanding are
> intentionally disallowed, but I was wondering if there was EL syntax that
> would support what I am trying to do, namely, set a URL based on a
> conditional, or if I should stick with <s:if>.
>
> Currently I have
>
> <s:if test="mn == #m.name">
>    <a href="#landing">${m.dispName}</a>
> </s:if>
> <s:else>
>    <a href="/internal!m?cName=${cName}&mName=${m.name}">${m.dispName}</a>
> </s:else>
>
> but would like to do it in a single line, something like
>
> <a href="${mn == m.name ? '#landing' : '/internal!m?cName=' + cName + '&mName=' + m.name}">${m.dispName}</a>

Yuck; unreadable. Stick it in a custom tag where it belongs. That much
computation doesn't belong in the mainline JSP.

Does the one-liner version not work?

Dave

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