update a component to include two differents forms

UI Components for JSF
Post Reply
stefanomagnoIII
Posts: 11
Joined: 03 Sep 2014, 17:27

04 Feb 2016, 12:30

Hi!

I have a page (called pageFlow.xhtml) which includes alternatively 2 subpages (step1 and step2).
The structure is this:

Code: Select all

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:component="http://java.sun.com/jsf/composite/component"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:portlet-client-model="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
	template="/layout/template.xhtml">

	<ui:define name="paramPage">
		<ui:param value="step#{pageFlow.currentStep}.xhtml" name="page" />
	</ui:define>

	<ui:define name="layout">
		<h:panelGroup layout="block" id="steps">
			<ui:include src="#{page}" />
		</h:panelGroup>
	</ui:define>
</ui:composition>
Step1.xhtml has a form that once completed and submitted correctly sends the user to step2.xhtml. So I update the panelGroup with id="steps" and I show the new page.
In the step2 there is another form, but now the commandButton connected with this form doesn't work. I tried even with the showcase, but every kind of form works only in the step1.xhtml. In step2.xhtml no forms work. I bind some function to the commandButton for onstart/oncomplete/onerror on ajax submit, but no errors are shown in the javascript console, neither on the server logs.

Moreover, in this latest form if I click on the commandButton, the managedBean (viewScoped) is reinitialized.

Can somebody explain me this strange behaviour?

thanks
Primefaces version: 5.3
JSF version: 2.0
server: Websphere Portal 8.0.0.1
IDE: RAD 8.5

smokeybandit
Posts: 277
Joined: 08 Jul 2013, 17:53

04 Feb 2016, 18:13

What does "doesn't work" mean? Does it submit the first form? Does it just do nothing when you click?

Be sure the button is actually in the form you think it is (and not in an embedded form)

stefanomagnoIII
Posts: 11
Joined: 03 Sep 2014, 17:27

08 Feb 2016, 18:38

smokeybandit wrote:What does "doesn't work" mean? Does it submit the first form? Does it just do nothing when you click?

Be sure the button is actually in the form you think it is (and not in an embedded form)
Hi

The first form is correctly submitted. After refreshing the form, the button doesn't call the action function. If I disable the ajax in the commandButton everything is fine. To be a little bit more clear, this is my situation:

+-----+--------+
| form | button|
+-----+--------+

After that the first form was submitted, I update the panel containing the form and the button, and the second form is shown. This is working with PF3.5.
With PF5.3 unfortunately this situation doesn't work anymore.
I found a possibly solution refreshing only the form without refreshing the button... But I don't know why I have to do this and don't know what changed from 3.5 to 5.3.

Thank you :)
Primefaces version: 5.3
JSF version: 2.0
server: Websphere Portal 8.0.0.1
IDE: RAD 8.5

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

09 Feb 2016, 12:19


stefanomagnoIII
Posts: 11
Joined: 03 Sep 2014, 17:27

09 Feb 2016, 18:29

I think is not a nested form.
This is a simplification of my situation (following the link you provided).
I use PrimeFaces 5.3, MyFaces 2.2x and no warnings/errors/exceptions are shown in the javascript console or on the server

rootPage.xhtml

Code: Select all

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:portlet-client-model="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
	xmlns:p="http://primefaces.org/ui" xmlns:tag="http://facelet/taglib"
	xmlns:component="http://java.sun.com/jsf/composite/component">

	<p:outputPanel id="containerForm">
		<h:form id="flowForm">
			<ui:include src="form#{prova.step}.xhtml" />
			<p:commandButton value="continua" update="flowForm"
				action="#{prova.nextForm}" />
		</h:form>
	</p:outputPanel>

</ui:composition>
form1.xhtml

Code: Select all

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:portlet-client-model="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
	xmlns:p="http://primefaces.org/ui" xmlns:tag="http://facelet/taglib"
	xmlns:component="http://java.sun.com/jsf/composite/component">
	
	<h:inputText value="#{prova.s1}" />	
</ui:composition>
form2.xhtml

Code: Select all

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:portlet-client-model="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
	xmlns:p="http://primefaces.org/ui" xmlns:tag="http://facelet/taglib"
	xmlns:component="http://java.sun.com/jsf/composite/component">
	
	<h:inputText value="#{prova.s2}" />	
</ui:composion>
Prova.java

Code: Select all

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = Prova.MB_PROVA)
@RequestScoped
public class Prova  implements Serializable {

	private static final long serialVersionUID = -8626311413217069298L;
	protected static final String MB_PROVA = "prova";
	
	private String s1;
	private String s2;
	private int step = 1;

	public String getS1() {
		return s1;
	}

	public void setS1(String s1) {
		this.s1 = s1;
	}
	
	public String getS2() {
		return s2;
	}

	public void setS2(String s2) {
		this.s2 = s2;
	}

	public int getStep() {
		return step;
	}

	public void setStep(int step) {
		this.step = step;
	}

	public void nextForm(){
		setStep(getStep() + 1);
	}
}
I think this is a working example :)
So, the first form works as expected, but after the update of the form, the second form is correctly displayed but the button action is not called anymore.

Thanks and I'm sorry if I wasn't clear before.
Primefaces version: 5.3
JSF version: 2.0
server: Websphere Portal 8.0.0.1
IDE: RAD 8.5

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 62 guests