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

combining s:set and s:property where the property retrieved is null has unexpected results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.14.1
    • Fix Version/s: 2.6
    • Component/s: Core Tags
    • Labels:
      None

      Description

      I have the following s:set definition:

      <s:set var="name"
      value="buildEnvironmentSearchView.name" scope="request"></s:set>

      which I further on use as such in a Dojo input:

      <input data-dojo-type="dijit/form/ComboBox"
      data-dojo-props="store:nameIdentificationStore, searchAttr:'name', value:'${name}'"
      name="buildEnvironmentSearchView.name"
      id="buildEnvironmentSearchView.name" />

      I needed to escape the value this generated for Javascript so single quotes didn't corrupt the dojo-props, so I replaced it with 

      <s:set var="name" scope="request">
      <s:property value="buildEnvironmentSearchView.name" escapeJavaScript="true"/>
      </s:set>

      This worked if buildEnvironmentSearchView.name is not null, but when it is evaluated to be null, instead of name being set to null, it was evaluated to the toString value of the top element on my valueStack: be.companyname.productname.client.struts2.layout.FieldFormatter@19b82032

      I'm not sure why this happens. In the end, I managed to resolve it by putting the s:property directly into the data-dojo-props object, but I don't really get why this happened. Is it intended that if you do an s:set with a null value, it returns the top value of the stack? This doesn't seem to be documented anywhere.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Kerkhofs Nate
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: