FYI I managed to work round this by changing the PortletExternalContextImpl.encodeNamespace to return null when called during an action request, instead of throwing an IllegalStateException.
My page now works, and it appears that the componenets still get assigned id's during the render stage. Should I be submitting a JIRA issue for this with a patch? John ----- Original Message ---- From: John Singleton <[EMAIL PROTECTED]> To: [email protected] Sent: Monday, 3 July, 2006 1:01:12 PM Subject: Portlet Can not call encodeNamespace() error I have a simple page (using facelets but I think its a faces problem). 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> backed by a 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. Can someone tell me what I'm doing wrong - or have i discovered a bug? I've include the relevant part of the stack trace below. Thanks John Nested Exception is java.lang.IllegalStateException: Can not call encodeNamespace() during a portlet ActionRequest at org.apache.myfaces.context.portlet.PortletExternalContextImpl.encodeNamespace(PortletExternalContextImpl.java:189) at javax.faces.component.UIViewRoot.createUniqueId(UIViewRoot.java:187) at javax.faces.component.UIComponentBase.getClientId(UIComponentBase.java:204) at javax.faces.component.UIData.getDataModel(UIData.java:760) at javax.faces.component.UIData.getRowCount(UIData.java:191) at javax.faces.component.UIData.processColumnChildren(UIData.java:685) at javax.faces.component.UIData.processUpdates(UIData.java:622) at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:645) at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:157) at org.apache.myfaces.lifecycle.LifecycleImpl.updateModelValues(LifecycleImpl.java:302) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:81) at org.apache.myfaces.portlet.MyFacesGenericPortlet.processAction(MyFacesGenericPortlet.java:220) at com.liferay.portal.shared.servlet.PortletServlet.service(PortletServlet.java:77) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499) at com.liferay.portlet.CachePortlet._invoke(CachePortlet.java:289) at com.liferay.portlet.CachePortlet.processAction(CachePortlet.java:142) at com.liferay.portal.action.LayoutAction._processPortletRequest(LayoutAction.java:232) at com.liferay.portal.action.LayoutAction._processActionRequest(LayoutAction.java:250) at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:86) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:185) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:415) at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:810) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.liferay.filters.strip.StripFilter.doFilter(StripFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:131) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.liferay.filters.compression.CompressionFilter.doFilter(CompressionFilter.java:112) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.doFilter(LayoutCacheFilter.java:197) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595)

