Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-1359

PortletExternalContextImpl.encodeNamespace called during portlet ActionRequest

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Abandoned
    • 1.1.5-SNAPSHOT
    • None
    • Portlet_Support
    • None
    • Facelets + Liferay 4.0.0

    Description

      Theis portlet fragment renders one of 2 components depending on the selection in the selectOneMenu:

      <div xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
      <h:form>
      <h:outputLabel for="list">foo</h:outputLabel>
      <h:selectOneMenu value="${booleanTest.choice}" id="list"><f:selectItems value="#

      {booleanTest.selectList}

      "/></h:selectOneMenu>
      <h:commandButton action="#

      {booleanTest.doIt}

      "/>
      </h:form>
      <h:outputText rendered="#

      {empty booleanTest.list}

      " value="Empty"/>
      <h:dataTable rendered="#

      {! empty booleanTest.list}

      " value="#

      {booleanTest.list}

      " var="l" border="1">
      <h:column>
      <f:facet name="header"><h:outputText value="Column"/></f:facet>
      <h:outputText value="#

      {l}

      "/>
      </h:column>
      </h:dataTable>
      </div>

      It's using this simple bean:

      public class BooleanTest {
      private List<String> list = new ArrayList<String>();
      private List<String> emptyList = new ArrayList<String>();
      private String choice = "Foo";
      private List<SelectItem> selectList = null;

      public List<String> getList() {
      if (choice.equals("Foo"))

      { return emptyList; }

      else {
      if (list.isEmpty())

      { list = new ArrayList<String>(); list.add("Hello"); list.add("World"); list.add("!!!!!"); }

      return list;
      }
      }

      public String doIt()

      { return "success"; }

      public List<SelectItem> getSelectList() {
      if (selectList == null)

      { selectList = new ArrayList<SelectItem>(); selectList.add(new SelectItem("Foo", "Foo")); selectList.add(new SelectItem("bar", "bar")); }

      return selectList;
      }

      public String getChoice()

      { return choice; }

      public void setChoice(String choice)

      { this.choice = choice; }

      }

      When I first add this portlet to a page, I get the drop down list, the submit button and the "empty" message. If I select the 'bar' entry in the list and click submit I get the error, " Can not call encodeNamespace() during a portlet ActionRequest"

      It seems to be because MyFacesGenericPortlet.processAction calls lifecycle.execute, which in turn starts createing components for the table (which wasn't in the first call to the page). This calls encodeNamespace for the new componenet IDs and thats when it falls over.

      I fixed this by changing PortletExternalContextImpl.encodeNamespace to return null instead of throwing an IllegalStateException. My application seems to be working well with this solution, but I don't know if it might have any knock on effects?

      Attachments

        Activity

          People

            Unassigned Unassigned
            johns John Snelson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: