[quote=limp13]Peguei o exemplo no site que tu me passou… com relação a passagem de parâmetro fixo ok… mas com relação a passagem de parâmetro de inputText por exemplo, eu nao compreendi muito bem… pq agora preciso pegar o valor do inputText e digamos passar para o método
Peguei este exemplo …
http://www.mkyong.com/jsf2/jsf-2-param-example/
Parte do codigo abaixo…
[code]<h:body>
<h1>JSF 2 param exemplo</h1>
<h:form id="form">
Digite seu nome :
<h:inputText size="10" value="#{user.name}" />
<br /><br />
<h:commandButton id="submitButton"
value="Submit - US" action="#{user.outcome}">
<f:param name="country" value="United States" />
</h:commandButton>
</h:form>
</h:body>
[/code]
Ao inves de passar esse valor “united States” fixo…
gostaria de pegar o valor do digitado pelo usuario no inputText:
<h:inputText size="10" value="#{user.name}" />
E passar para o método
]
action="#{user.outcome}"
[/quote]
Bom dia amigo, veja se o seguinte exemplo lhe eh util:
<!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">
<h:head>
<title>Segurança</title>
</h:head>
<h:body>
<h:form id="id1">
<h:panelGrid columns="4" width="80%" id="painelPescador">
<h:outputLabel for="id2" value="Name: " />
<h:inputText id="id3" value="#{countryMB.country.name}" />
<h:panelGrid columns="3">
<p:commandButton value="Submit" action="#{countryMB.outcome}"
ajax="false" />
</h:panelGrid>
</h:panelGrid>
</h:form>
</h:body>
</html>
[code]package br.com.sisgappe.view;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import br.com.sisgappe.model.entity.Country;
@ManagedBean
@ViewScoped
public class CountryMB {
private Country country = new Country();
public void setCountry(Country country) {
this.country = country;
}
public Country getCountry() {
return country;
}
public void outcome() {
System.out.println(this.getCountry().getName());
}
}
[/code]
[code]package br.com.sisgappe.model.entity;
import java.io.Serializable;
public class Country implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
[/code]
[]'s