Board index JavaServer Faces General Portlet p:commandButton works only when immediate=true

Portlet p:commandButton works only when immediate=true

Components, Ajax Framework, Utilities and More.


Posts: 17
Hi All,
Liferay 6.0, PF 3.0 SNAP (also tried with PF 2.2), Tomcat 6.0
I'm new to PF, and I'm having issues with a simple use case where from a TAB, I open a Dialog and click Submit button to submit form data.
But the looks like p:commandButton only works when immediate=true, but that's not helping me as I've to submit other form data also.

I also noticed the simlar issue with h:selectManyCheckBox, but there immediate=true was a viable workaround, but in this case I must NOT HAVE immediate=true.

Note: when I deployed the PF 3.0 Showcase war locally on Tomcat 6.0, everything is fine, but I'm noticing this in Portal env only.

also, anybody pl correct me on my web.xml config for PF if you see any issues.

this is the code for one of the tabs:

<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">

<h:panelGrid columns="1" cellpadding="5">
<p:commandButton id="basic" value="Basic" onclick="dlg1.show();" type="button" />
<p:commandButton value="Modal" onclick="dlg2.show();" type="button"/>
<p:commandButton value="Effects" onclick="dlg3.show();" type="button" />

</h:panelGrid>

<p:growl id="growl" showDetail="true" life="3000" />

<p:dialog header="Modal Dialog" widgetVar="dlg1" modal="false" height="400" width="300">
<h:form>

<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="instId" value="Username: *" />
<p:inputText value="#{institutionBean.instId}"
id="instId" required="true" label="username" />

<h:outputLabel for="instName" value="Password: * " />
<h:inputSecret value="#{institutionBean.instName}"
id="instName" required="true" label="password" />

<f:facet name="footer">
<p:commandButton value="Login" update="growl"
actionListener="#{institutionBean.uploadAgreement}" />
</f:facet>
</h:panelGrid>

</h:form>

</p:dialog>

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
<h:outputText value="This is a Modal Dialog." />
</p:dialog>

<p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="explode" height="100">
<h:outputText value="This dialog has nice effects." />
</p:dialog>

</f:view>


code from InstitutionBean:

private String instName;

public void uploadAgreement(ActionEvent ace){
System.out.println("uploadAgreement instName "+instName);
}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<display-name>Portlet4-portlet</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>

<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>

<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>512000</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/temp</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

<listener>
<listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>1</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.portletfaces.bridge.GenericFacesPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>1</servlet-name>
<url-pattern>/1New/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/xhtml/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>
org.primefaces.resource.ResourceServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>

<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

</web-app>


Posts: 258
Location: Turkey
Hi,

it seems you face a problem with required="true" fields, can you test with removing all your required="true" code and try again w/o immediate="true"

if this is the case, please use process property to process only necessary fields when you do the submit.


Posts: 17
Thanks Yigit for the quick response.

Actually when I dont use immediate=true, then on the server console, i see the the Liferay prints, meaning that request is hitting the server, but from Server-->Portal-->PortletBridge-->PF, somewhere someone is not able to parse the URL to appropriate resource/destination.

One more request Yigit, is there any tutorial on how to use Facestrace with PF, or any suggestions on how to debug PF source from within a portlet.

07:44:11,752 WARN [ThemeLocalServiceImpl:121] No theme found for specified theme id netacad_WAR_netacadtheme. Returning the default theme.
07:44:11,754 WARN [ThemeLocalServiceImpl:121] No theme found for specified theme id netacad_WAR_netacadtheme. Returning the default theme.

Here is the modified xhtml code:

<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
>

<h:panelGrid columns="1" cellpadding="5">
<p:commandButton id="basic" value="Basic" onclick="dlg1.show();" type="button" />
<p:commandButton value="Modal" onclick="dlg2.show();" type="button"/>
<p:commandButton value="Effects" onclick="dlg3.show();" type="button" />

</h:panelGrid>

<p:growl id="growl" showDetail="true" life="3000" />

<p:dialog header="Modal Dialog" widgetVar="dlg1" modal="false" height="400" width="300">
<h:form>

<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="instId" value="Username: *" />
<p:inputText value="#{institutionBean.instId}"
id="instId" label="username" />

<h:outputLabel for="instName" value="Password: * " />
<h:inputSecret value="#{institutionBean.instName}"
id="instName" label="password" />

<f:facet name="footer">
<p:commandButton value="Login" update="growl"
actionListener="#{institutionBean.uploadAgreement}" process="instId, instName"/>
</f:facet>
</h:panelGrid>

</h:form>

</p:dialog>

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
<h:outputText value="This is a Modal Dialog." />
</p:dialog>

<p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="explode" height="100">
<h:outputText value="This dialog has nice effects." />
</p:dialog>

</f:view>


Return to General