Struts 2 - struts tag with boolean property

Struts 2 - struts tag <s:if test= "booleanVaue" > with boolean property

Always remember two points --

1) Check your bean (.java) file for getter, setter for boolean type value
  private boolean isTest;
  private boolean hasCheck;

   public boolean isTest() {
        return isTest;
    }

    public void setTest(boolean isTest) {
        this.isTest= isTest;
    }


   public boolean isHasCheck() {
        return hasCheck;
    }

    public void setHasCheck(boolean hasCheck) {
        this.hasCheck= hasCheck;
    }

-------------------------------------------------------------------------

On a jsp page if you are using these two variables in a <s:if> conditions

<s:if test="isTest">
// This will not work, will always return blank value as isTest is conflicting with getter method isTest();
</s:if>

<s:if test="hasCheck">
  // This will work whatever the value you have set from action
</s:if>

Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI