Processing a form from another form with commandButton

UI Components for JSF
Post Reply
4l3x
Posts: 6
Joined: 22 Aug 2011, 11:35

24 Oct 2011, 15:43

Hi all,

I want to process a form but I want that the event was fired from other form throught a p:commandButton. I put here some code to better explain myself :) .

This is the facelets page:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:sd="http://java.sun.com/jsf/composite/customTag">

<h:head>
	<title>The example</title>
</h:head>
<h:body>
<h:form id="form1">
	<p:commandButton value="Test" id="buttonSave" ajax="true" actionListener="#{ejemplo.bTest}" update=":form3" process="@this :form2"/>
</h:form>

<h:form id="form2">	
	<p:inputText id="id_field" value="#{ejemplo.texto}" />
</h:form>

<h:form id="form3">		
	<h:outputText id="id_f1" value="#{ejemplo.texto}" />
</h:form>
</h:body>
</html>


I want to process the inputText that is in the form2, but the button is in the form1, but the value in the inputText from form2 isn't sent in the request.
Then I want to update the value in the outputText of the form3, this works properly with the configuration in the example, and I suppose that configuring the same way the process attribute it will work but it doesn't.

This is the backing Bean:

Code: Select all

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "ejemplo")
@SessionScoped
public class Ejemplo {

	String texto;

	public void bTest() {
		System.out.println("Ejemplo: " + texto);

	}

	public String getTexto() {
		return texto;
	}

	public void setTexto(String texto) {
		this.texto = texto;
	}
}
Is there a way to make this work? Or a commandButton can only process fields in his own form?

I want to know if there is a way to do that I explain before, process a form from another form.
Primefaces 2.2.1/ Migrating to 3.0M4
MyFaces 2.1.2
Tomcat 7.0.14

MarkDones
Posts: 5
Joined: 03 Oct 2012, 14:48

03 Oct 2012, 15:46


getlink
Posts: 1
Joined: 14 Feb 2014, 05:06

14 Feb 2014, 05:18

MarkDones wrote:Please see http://forum.primefaces.org/viewtopic.php/form processing?f=3&t=24915
seems like like a good website. thank you i hope i can solve my problem here.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests