PortletExternalContextImpl.encodeNamespace called during portlet ActionRequest
------------------------------------------------------------------------------
Key: MYFACES-1359
URL: http://issues.apache.org/jira/browse/MYFACES-1359
Project: MyFaces Core
Type: Bug
Components: Portlet_Support
Versions: 1.1.5-SNAPSHOT
Environment: Facelets + Liferay 4.0.0
Reporter: John Singleton
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?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira