I've read and re-read the Struts2 guides on OGNL and the Struts2 tags (and
the OGNL web site guide to comparisons).

Problem: I wanted to protect fields on a form if the user was not the
"owner" of the domain object.
My approach was going to be to test that the form was either:
a) empty, so a new instance was being created so fields should not be
protected.
b) the remoteUser was the same as the "owner" of the existing object, again
no protection needed.
c) Otherwise I wanted to "disable" all of the form fields and just allow the
data to be viewed.

I looked at the example of the Appfuse userForm.jsp and found an example
"s:if" statement that appeared like it should be a basis for this to work.
It was:

  <s:if test="ticket.id == null | ticket.owner.username ==
#request['remoteUser']">
      <s:set name="protect" value="%{'false'}"/>
  </s:if>
  <s:else>
      <s:set name="protect" value="%{'true'}"/>
  </s:else>
    ...
  <s:textfield id="..." disabled="protect"/>


Well this did not work as expected. I tried numerous combinations, including 
disabled="#protect". I never could get it to work right. I've ended up
reverting back to regular JSTL c:if tags, but using these in combination
with s:if tags appears to not work consistently.

Any ideas on how to do this would be greatly appreciated. I've been working
with an appfuse/struts-resume app for over five years. For a new app we are
doing, we decided it was time to move to Maven, Appfuse 2.0, Struts2,
Spring. The code is so much cleaner, but the learning curve on a couple of
things has really bit me hard!
-- 
View this message in context: 
http://www.nabble.com/Struts2-%22s%3Aif%22-tag-comparisons-and-OGNL-tp16518434s2369p16518434.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


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

Reply via email to