0

I am using the struts tag inside of a struts iterator tag to control what displays in one of my fields as follows.

<s:iterator value="commentViewList" >
  <s:if test="%{documentInfo.documentId != 0}">
    <div class="col-sm-2 col-xs-12 text-center"><s:a href="%{documentLink}" tabindex="19"><s:text name="yes"/></s:a></div>  
  </s:if>

  <s:else>
    <div class="col-sm-2 col-xs-12 text-center"><s:property value=""/></div>  
  </s:else>

It works fine but I would like to replace the 0 in the test with a reference to a noValueId int variable I have defined in my action page. That will allow me to make one change if I ever need to change what I compare documentInfo.documentId to. I use this value in my action page also. Any help would be appreciated!

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
ponder275
  • 903
  • 2
  • 12
  • 33
  • 1
    Also `documentInfo.documentId` is a variable from your Action class. You just need an attribute with its getter, or even only the getter. What's the problem ? :| – Andrea Ligios Oct 29 '15 at 14:41
  • 1
    Originally I tried to reference a static variable (it was a static final constant) and when it didn't work I put the variable in a hidden field on my jsp page but that didn't help so I removed the hidden field. I then read where you can't reference a static variable so I changed it to a non-static variable but it still didn't work but I had forgotten to put the hidden field back in. As I was writing a response to your comment I realized what I had done so I put the hidden field back in and it works. Thanks for the comment! – ponder275 Oct 30 '15 at 14:08
  • You can access static field. See http://stackoverflow.com/q/16063819/1700321. – Aleksandr M Nov 02 '15 at 10:07
  • @AleksandrM So I can treat a static field just like an Enum? – ponder275 Nov 02 '15 at 16:23
  • 1
    You can access it like enum, using `@package.Class@FIELD`. – Aleksandr M Nov 02 '15 at 18:08
  • Thanks for the information! – ponder275 Nov 02 '15 at 19:27

0 Answers0