javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2562

Can not create Composite Component with multiple attributes programatically

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-m04
    • Fix Version/s: 2.2.0-m06
    • Component/s: composite components
    • Labels:
      None
    • Environment:

      Glassfish 3.1.2 Linux

      Description

      I tried to create a composite component like this

      Map<String, Object> attrs=new HashMap<String, Object>();
      attrs.put("pager", pagerObject);
      attrs.put("pagecontent", dataID);
      FaceletFactory faceletFactory = (FaceletFactory) FactoryFinder
      				.getFactory(FactoryFinder.FACELET_FACTORY);
      result = faceletFactory.createComponent(
      				"http://java.sun.com/jsf/composite/" + library, name, attrs);
      

      Where attrs contains more than one attributes, I get this error

      Error Parsing //opt/glassfish3/glassfish/domains/domain1/generated/jsp/flexims/mojarra4543755225647727870.tmp: Error Traced[line: 2] Element type "j:pager" must be followed by either attribute specifications, ">" or "/>".

      I traced the error down to line 337 in com.sun.faces.facelets.impl.DefaultFaceletFactory

        if (!attributes.isEmpty()) {
                      for (Map.Entry<String,Object> attr : attributes.entrySet()) {
      line 337:                    osw.append(attr.getKey()).append("=\"").append(attr.getValue().toString()).append("\"");
                      }
                  }
      

      The problem is there is no space between multiple xml attributes so the generated xml is not well formatted.

      As a workaround, I added a space before attribute name when creating attrs.

      attrs.put(" pagecontent", dataID);
      

      Note that I added extra space character before attribute name pagecontent.

        Activity

        Hide
        jasonzhang2002gmailcom added a comment -

        Will look the latest 2.1 release. But this is a new feature in JSF 2.2. I double 2.1 support this. This is very easy to fix. I already pin it down to the code location. Developer only needs to add an extra space character in generated xml.

        Show
        jasonzhang2002gmailcom added a comment - Will look the latest 2.1 release. But this is a new feature in JSF 2.2. I double 2.1 support this. This is very easy to fix. I already pin it down to the code location. Developer only needs to add an extra space character in generated xml.
        Show
        Ed Burns added a comment - Safe to close if < http://hudson-sca.us.oracle.com/view/MOJARRA_ALL/job/MOJARRA_TRUNK_GLASSFISH_TRUNK_MINUS_ONE_NO_CLUSTER/602/ > and < http://tim-vm9.us.oracle.com:7070/hudson/view/Trunk/job/trunk-test-glassfish-3_1_2_2/59/ > are clean.
        Show
        Ed Burns added a comment - < http://hudson-sca.us.oracle.com/view/MOJARRA_ALL/job/MOJARRA_TRUNK_GLASSFISH_TRUNK_MINUS_ONE_NO_CLUSTER/602/ > and < http://tim-vm9.us.oracle.com:7070/hudson/view/Trunk/job/trunk-test-glassfish-3_1_2_2/59/ > are clean.

          People

          • Assignee:
            Ed Burns
            Reporter:
            jasonzhang2002gmailcom
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 51 minutes
              51m