Felipe Rodrigues wrote:
Hi Laurie,

From your example I can see that the best way is to use the OGNL instead of
EL in Struts tags.
But, will OGNL work exactly as EL to get values from session, pageContext,
request and application?
I thought OGNL was only for Struts stack. I didn't realize that I could use
it as alternative for EL.

OGNL can do everything that the JSTL EL can do and more. Some people prefer to stick with just OGNL, others like to mix and match. The only conflict I'm aware of is OGNL's map-literal construct, "#{'a':'1','b':'2')" which 'confuses' EL-aware containers ;-)

When you mean a stand-alone test case, you mean a little app that reproduces
this behavior or a unit test for action?
I don't think a unit test will get this behavior. Let me know and I will

I mean a 'little app' or at least a simple JSP page and supporting code/config snippets that someone can easily plug into an existing app.

make it, because even if this %{} make the trick, I believe struts should be
really compliant with EL standard. don't you think?

Yes, Struts should work as expected with EL expressions. It's just a case of expecting the right things ;-) Without seeing your real code and/or having a test case to reliably reproduce the problem, though, there's no way to say for sure where the issue lies.

L.

Thanks once again,

Felipe


Laurie Harper wrote:
Well, as I said, the 'value' attribute is evaluated by OGNL, so what's going to happen here is:

  1. the container will evaluate the EL expression ${mapItem.value.id}
  2. the result of 1. (e.g. int '99') will be passed into the custom
action
  3. Struts will attempt to evaluate the value '99' as an OGNL expression
4. If the result of 3. is not a String, Struts will apply the appropriate conversion, before calling setSomeAtt() on your action

Assuming ${mapItem.value.id} returns an int or Integer value, I would *expect* that OGNL would 'do the right thing' with it. However, you may want to try being more explicit: value="%{mapItem.value.id}"

What you have below doesn't look wrong particularly wrong, so if the above change doesn't do the trick, post your exact, real code, to be sure there isn't something odd in there.

I'd still suggest you boil this down to a simple, stand-alone test case that others could use to test the behaviour. If this is a bug somewhere in Struts, a test case will greatly improve the chances of it being tracked down and fixed quickly.

L.

Felipe Rodrigues wrote:
I'm sorry, but I'm away from my code, so I'll try to reproduce here.
The code is pretty simple.

------------------------------------------------------ END OF CODE
--------------------------------------------

The JSP:
<c:foreach items="somMap" var="mapItem">

   <s:url action="Home!loadHome" id="myURL">
      <s:param name="someAtt" value="${mapItem.value.id}"/>
   </s:url>

   <s:a href="%{myURL}" notifyTopic="myTopic" theme="ajax"
target="someDiv">MyLink</s:a>

</c:forEach>

=================================

The Action

public class HomeAction {

  private String someAtt;

 public void setSomeAtt(String someAtt){
  //Here someAtt has the value of param, and the appended " .
   this.someAtt = someAtt;
 }

  public String loadHome(){
     // some stuff here.
     return "success";
  }

}

------------------------------------------------------ END OF CODE
--------------------------------------------

I think this cover all things. There is some others details, like all of
that is inside a TabbedPannel, but I don't think this matters.
When I'm debbugging I can see the value in the session represented by
this
one ${mapItem.value.id} is ok (without " )
but when I got my breakpoint at setSomeAtt the value has the " as its
last
charracter.

So weird, but I'm wondering if no one else have seen this behavior.

If this code is not enougth, let me know and tomorrow I can send you the
real piece of code.

Thanks,


Felipe





Laurie Harper wrote:
Felipe Rodrigues wrote:
Hi guys,

Sometimes when I use <s:param tag, the value that I got in my action
has
a "
appended to it. I can treat that by replacing this, but it is not a
good
solution.
Does anybody heard anything about that? I've looked at the source code of param tag in the Struts source code,
and
there is a findValue(String expr) that calls
ValueStack.findValue(String
expr) as well. What exactly is that expr (to me seems to be the name we
define in param tag). Anyway, I didn't found anything wrong there, but
I
don't know how the value get there.
The param tag's 'value' attribute is evaluated -- i.e. the value you supply is treated as an OGNL expression. See the tag syntax documentation for details.

Without seeing an example of this behaviour (i.e. some code/markup that reproduces the problem) it's going to be difficult to diagnose. Can you come up with a minimal test case that demonstrates the behaviour you're describing?

L.

[1] http://struts.apache.org/2.x/docs/tag-syntax.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to