Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Abandoned
-
1.1.5-SNAPSHOT
-
None
-
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="#
"/></h:selectOneMenu>
<h:commandButton action="#
"/>
</h:form>
<h:outputText rendered="#
" value="Empty"/>
<h:dataTable rendered="#
" value="#
{booleanTest.list}" var="l" border="1">
<h:column>
<f:facet name="header"><h:outputText value="Column"/></f:facet>
<h:outputText value="#
"/>
</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"))
else {
if (list.isEmpty())
return list;
}
}
public String doIt()
{ return "success"; } public List<SelectItem> getSelectList() {
if (selectList == null)
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?