Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2457

Action boolean properties values are not available to XSLTResult.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.10, 2.0.11, 2.1.0
    • 2.1.2
    • Other
    • None
    • Windows XP, JDK 1.5

    Description

      For instance the action BooleanAction.java:
      ------------------------------------------------------------------
      import com.opensymphony.xwork2.Action;

      public class BooleanAction implements Action{

      private boolean testFalse = false;

      public String execute() throws Exception

      { return this.SUCCESS;}

      public boolean isTestFalse()

      { return testFalse; }

      public void setTestFalse(boolean testFalse)

      { this.testFalse = testFalse;}

      }
      ------------------------------------------------------------------

      will produce the result:
      <result>
      <testFalse/>
      </result>

      but should produce :

      <result>
      <testFalse>false</testFalse>
      </result>

      The diff below fixes the problem with org.apache.struts2.views.xslt.AdapterFactory creating a BeanAdapter for a java.lang.Boolean value:

      Index: AdapterFactory.java
      ===================================================================
      — AdapterFactory.java (revision 615211)
      +++ AdapterFactory.java (working copy)
      @@ -146,7 +146,7 @@

      if (valueType.isArray())
      adapterClass = ArrayAdapter.class;

      • else if (value instanceof String || value instanceof Number || valueType.isPrimitive())
        + else if (value instanceof String || value instanceof Number || value instanceof Boolean || valueType.isPrimitive())
        adapterClass = StringAdapter.class;
        else if (value instanceof Collection)
        adapterClass = CollectionAdapter.class;

      Attachments

        Activity

          People

            mrdon Donald J. Brown
            smwolke Steve Wolke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: