multiple forms on page submitting to first form? - forms

I have three forms in one page, each calls a different backing bean, but when i use a form other than the first one the call goes three times to the first form, each form persists into a DB.Table and the persistence is being done three times when i click the commandButtons, is this bad practice or am I missing something in my code ?
<h:form id="ciclista-form" >
<div id="ciclista-link"><h1>Crear Ciclista</h1></div>
// inputTexts ... .. .
<h:commandButton action="#{ciclistaBean.guardarCiclista()}" value="Guardar Ciclista" class="ciclista-form-btn"/>
</h:form>
<h:form id="Etapa-form" > Etapa-form -->
<div id="Etapa-link"><h1>Crear Etapa</h1></div> -->
// input texts . ..
<h:commandButton action="#{etapaBean.guardarEtapa()}" value="Guardar Etapa" class="carrera-form-btn"/> -->
</h:form> Etapa-form -->
<h:form id="carrera-form" > <!-- carrera-form -->
<div id="carrera-link"><h1>Crear carrera</h1></div>
// input texts . . .
<h:commandButton action="#{carreraBean.guardarCarrera()}" value="Guardar Carrera" class="etapa-form-btn" />
</h:form> <!-- carrera-form -->
all calls go to first form, why is this ?

The snipped you show seems ok, what type are your beans? What scope do they have? Have they dependencies to another?
I tried to follow you idea with following code, it works in my setup...
<h:body>
<h:form id="ciclista-form">
<div id="ciclista-link">
<h1>Crear Ciclista</h1>
<h:inputText value="#{ciclistaBean.text}"/>
</div>
<h:commandButton action="#{ciclistaBean.guardarCiclista()}" value="Guardar Ciclista" class="ciclista-form-btn" />
</h:form>
<h:form id="Etapa-form">
<div id="Etapa-link">
<h1>Crear Etapa</h1>
<h:inputText value="#{etapaBean.text}"/>
</div>
<h:commandButton action="#{etapaBean.guardarEtapa()}" value="Guardar Etapa" class="carrera-form-btn" />
</h:form>
<h:form id="carrera-form">
<div id="carrera-link">
<h1>Crear carrera</h1>
<h:inputText value="#{carreraBean.text}"/>
</div>
<h:commandButton action="#{carreraBean.guardarCarrera()}" value="Guardar Carrera" class="etapa-form-btn" />
</h:form>
</h:body>
with three independend #RequestScoped beans
#ManagedBean(name = "ciclistaBean")
#RequestScoped
public class SO26836137_F1 {
private String text;
public void guardarCiclista() {
System.out.println("Form 1 submitted: " + text);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
#ManagedBean(name = "etapaBean")
#RequestScoped
public class SO26836137_F2 {
private String text;
public void guardarEtapa() {
System.out.println("Form 2 submitted: " + text);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
#ManagedBean(name = "carreraBean")
#RequestScoped
public class SO26836137_F3 {
private String text;
public void guardarCarrera() {
System.out.println("Form 3 submitted: " + text);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}

Related

How to show/hide an element in real time (Blazor)?

I have an image I would like to display only after a user has filled in all text fields.
I have tried using disabled attribute, but that does not seem to work. Any other insights?
Here is my current code:
<EditForm EditContext="#EditContext" style="max-width:800px;" onkeydown="javascript: DisableEnterKey();">
<FluentValidator />
<img src="images/approval-16-grey.ico" alt="Image" disabled="#OkayDisabled">
<p class="statp">How many families and/or individuals are living on your land?</p><br />
<label class="statlabel" for="amountOfFamilies">Amount of families:</label><br />
<InputNumber id="fams" for="indivNum" class="input" #bind-Value="#familyData.IndividualAmount" onwheel="this.blur()" placeholder="Families..." autofocus />
<ValidationMessage For="() => familyData.IndividualAmount" />
<br /><hr class="statHR" />
<label class="statlabel" for="amountOfIndividuals">Amount of single individuals: </label><br />
<InputNumber id="individuals" for="famNum" class="input" #bind-Value="#familyData.FamilyAmount" onwheel="this.blur()" placeholder="Individuals..."/>
<ValidationMessage For="() => familyData.FamilyAmount" />
<br /><hr class="statHR" />
<label class="statlabel" for="names"> Please enter all of the names here:</label><br />
<InputTextArea id="names" class="textArea" rows="4" cols="18" #bind-Value="#PersonName" placeholder="Names of all individuals..." />
<ValidationMessage For="() => familyData.PersonName" />
</EditForm>
</div>
</ul>
#code
{
private EditContext? EditContext;
public FamilyData Model = new FamilyData();
protected string OkayDisabled { get; set; } = "disabled";
protected override void OnInitialized()
{
EditContext = new EditContext(Model);
EditContext.OnFieldChanged += EditContext_OnFieldChanged;
base.OnInitialized();
}
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
SetOkDisabledStatus();
}
private void EditContext_OnFieldChanged(object? sender, FieldChangedEventArgs e)
{
SetOkDisabledStatus();
}
private void SetOkDisabledStatus()
{
if(EditContext.Validate())
{
OkayDisabled = null;
}
else
{
OkayDisabled = "disabled";
}
}
}
The hidden html attribute also works to hide an element.
<p hidden>This paragraph should be hidden.</p>
To bind to Model:
<p hidden="#HideLabel">I am Hidden When HideLabel == true</p>
<p hidden="#(!HideLabel)">I am Hidden when Hidelabel == false</p>
<button #onclick="#Toggle">Show/Hide</button>
#code {
private bool HideLabel {get;set;} = false;
private void Toggle()
{
HideLabel = !HideLabel;
}
}
Edit: You can also use a CSS class to hide/show an element:
<div class="font-italic #(HideLabel ? "d-none" : "d-show")">
I am Hidden When HideLabel == true
</div>
Change OkayDisabled to a bool, and then around your image do this
#if (!OkayDisabled)
{
<img src=".....whatever" etc />
}
You might also want to add #bind:event="oninput" wherever you use an #bind.
Instead of binding your flag to the disabled attribute (an image's disabled attribute just grays it out), I would bind it to a css class that has display: none;
.hidden {
display: none;
}
<img class="#(ShouldShowImage? "hidden" : string.Empty)">
didn't used it within editform but should work
#if(OkayDisabled)
{
<img src="images/approval-16-grey.ico" >

Rendering a form based on bean field value

I want to ask user to input password before submitting a file. So <h:panelGroup> should be rendered after hit the Submit button. But, <h:panelGoup> never be rendered.
test.xhtml
<ui:define name="body">
<h:form id="uploadForm" enctype="multipart/form-data">
<table>
<t:inputFileUpload id="uploadedFile" storage="file"
value="#{UpdateBean.uploadedFile}"/>
<h:commandButton value="Submit" action="#{UpdateBean.submit()}"/>
</table>
</h:form>
<h:panelGroup id="checkPassword" rendered="#{UpdateBean.submitIsPerformed}">
<h:outputText id="message" value="${UpdateBean.message}" />
<h:inputText id="password" value="#{UpdateBean.password}" />
<h:commandButton value="submit" action="#{UpdateBean.submitPassword()}"/>
</h:panelGroup>
</ui:define>
UpdateBean.java
#ManagedBean(name = "UpdateBean")
#SessionScoped
public class UpdateBean {
protected boolean submitIsPerformed = false;
protected String password = "";
protected String message = "Input your password ";
// omit getter and setter
public void submit() {
this.setSubmitIsPerformed(true);
System.out.println(submitIsPerformed); // output is true
while(true) {
if(password.equals("123")) {
break;
}
}
// then process uploadedFile
}
public void submitPassword(){
if(password.equals("123")) {
message = "Password confirmed !";
} else {
message = "Password is wrong !";
}
}
}
Your mistake is in the submit() method:
while(true) {
if(password.equals("123")) {
break;
}
}
The while(true) prevents the action method from returning. As long as the action method doesn't return, the server won't return the HTTP response with the updated view. Effectively, one of your server's CPU is stuck into 100% and the client is infinitely waiting for HTTP response. You should have noticed it by checking the browser's progress indicator, if it has one.
You should basically immediately return after toggling the boolean:
public void submit() {
submitIsPerformed = true;
}
And perform the password checking and upload file saving in submitPassword() method. However, as this isn't in the same form, the uploaded file will get lost. Even if you put it in the same form, it would be uploaded twice. But that's a different problem. I suggest to do the job the other way round.
Follow the suggestion from #BalusC, this is my updated code.
test.xhtml
<ui:define name="body">
<h:form>
<h:commandButton value="Upload a file" action="#{UpdateBean.submit()}">
<f:ajax render=":checkPassword" />
</h:commandButton>
</h:form>
<h:form id="checkPassword" styleClass="toggle" rendered="#{UpdateBean.submitIsPerformed}">
<table>
<tr>
<td><h:outputText value="Password" /></td>
<td><h:inputText id="password" value="#{UpdateBean.password}" /></td>
<td>
<h:commandButton value="Submit" action="#{UpdateBean.submitPassword()}">
<f:ajax execute="password" render=":uploadFile" />
</h:commandButton>
</td>
</tr>
</table>
</h:form>
<h:form id="uploadFile" enctype="multipart/form-data"
styleClass="toggle" rendered="#{UpdateBean.uploadFileIsPerformed}">
<t:inputFileUpload id="uploadedFile" storage="file"
value="#{UpdateBean.uploadedFile}">
</t:inputFileUpload>
<h:commandButton value="Submit" action="#{UpdateBean.uploadFile()}" />
</h:form>
</ui:define>
UploadBean.java
public String submit() {
setSubmitIsPerformed(true);
return "SUCCESS";
}
public String submitPassword(){
if(password.equals("123"){
setUploadFileIsPerformed(true);
setSubmitIsPerformed(false);
}
return "SUCCESS";
}
public String uploadFile(){
return "SUCCESS";
}

Dynamic JSF Form: Link between input field and Bean does not work

I created a dynamic Form where the user can add multiple calendar input fields by clicking a command button. My Problem is, that the connection between View and Been is broken. Submitting the form returns the Date created previously in the Bean initially and not the Date submitted by the user. How to fix it?
EDIT: Changing a date and extending the form afterwards without saving before leads to losing the changed date(s). Even with the solution with a wrapper object provided by #wittakarn.
EDIT: The ajax snippet seems to be the problem, when I strip that out it works.
DynamicFormBean:
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class DynamicformBean implements Serializable {
private static final Logger LOGGER = Logger.getLogger(DynamicformBean.class.getName());
private List<Date> values;
#PostConstruct
public void init() {
values = new LinkedList<>();
values.add(new Date());
}
public void submit() {
// save values in database
LOGGER.info(values.toString());
}
public void extend() {
values.add(new Date());
}
public void setValues(List<Date> values) {
this.values = values;
}
public List<Date> getValues() {
return values;
}
}
My View: dynamicform.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:body>
<h:form><h2>Dynamicform example</h2>
<ui:repeat value="#{dynamicformBean.values}" var="value">
<p:outputLabel for="mask" value="Mask:" />
<p:calendar id="mask" value="#{value}" pattern="dd.MM.yyyy" mask="true">
<f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET" />
</p:calendar>
<br />
</ui:repeat>
<h:commandButton value="Extend">
<f:ajax listener="#{dynamicformBean.extend}" process="#form" render="#form" />
</h:commandButton>
<h:commandButton action="#{dynamicformBean.submit}" value="Save" />
</h:form>
</h:body>
</f:view>
The log just prints elements with the current date.
I cannot tell in detail why connection between View and Been is broken, but when I wrap object date into Data class as following code. The problem is gone.
xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head><title>Dynamicform example</title></h:head>
<h:body>
<h:form>
<h2>Dynamicform example</h2>
<ui:repeat value="#{dynamicformBean.values}" var="value">
<p:outputLabel for="mask" value="Mask:" />
<p:calendar id="mask"
value="#{value.date}"
pattern="dd.MM.yyyy" mask="true">
<f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET" />
</p:calendar>
<br/>
</ui:repeat>
<h:commandButton value="Extend">
<f:ajax render="#form"
listener="#{dynamicformBean.extend}"/>
</h:commandButton>
<h:commandButton action="#{dynamicformBean.submit}" value="Save"/>
</h:form>
</h:body>
</f:view>
</html>
managedbean
#ManagedBean(name = "dynamicformBean")
#ViewScoped
public class DynamicformBean implements Serializable {
private static final Logger LOGGER = Logger.getLogger(DynamicformBean.class.getName());
private List<Data> values;
#PostConstruct
public void init() {
values = new LinkedList<Data>();
values.add(new Data());
}
public void submit() {
// save values in database
for (Data data : values) {
LOGGER.info(data.getDate().toString());
}
}
public List<Data> getValues() {
return values;
}
public void setValues(List<Data> values) {
this.values = values;
}
public void extend(AjaxBehaviorEvent event) {
LOGGER.info("extend");
values.add(new Data());
}
}
Data object
import java.io.Serializable;
import java.util.Date;
public class Data implements Serializable {
private Date date;
public Data(){
date = new Date();
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
However, you should use JSF Standard tags h:head. PrimeFaces uses it to include the necessary java script and CSS code for the Ajax works and fancy look'n'feel.

xhtml don't recognize methods declared in managed Bean

in my XHTML page I can't call methods declared in managed bean, I'm new to this platform , I'd like that some one clarifies this to me. I'm working on a JSF 2.1 project with JPA on Eclipse Juno 4.2
here's my managed been code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package managedBean;
import java.util.List;
import javax.ejb.Local;
import model.*;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import service.EmpFacadeLocal;
/**
*
* #author Louuup
*/
#ManagedBean (name= "empbean")
#RequestScoped
#ViewScoped
public class EmpManagedBean {
public Employe emp;
#EJB
public EmpFacadeLocal empfacadelocal;
public Boolean saisie;
private List<Employe> emps;
private String iddd;
private Employe selectedemp;
private List<Employe> filteredemps;
private Employe[] selectedemps;
/**
* Creates a new instance of EmpManagedBean
*/
public EmpManagedBean() {
emps = new ArrayList<Employe>();
}
#PostConstruct
public void initEmp(){
emp = new Employe();
saisie = false;
emps = empfacadelocal.getEmpRq("");
}
public Employe getEmp() {
return emp;
}
public void setEmp(Employe emp) {
this.emp = emp;
}
public Boolean getSaisie() {
return saisie;
}
public void setSaisie(Boolean saisie) {
this.saisie = saisie;
}
public List<Employe> getEmps() {
return emps;
}
public void setEmps(List<Employe> emps) {
this.emps = emps;
}
public String getIddd() {
return iddd;
}
public void setIddd(String iddd) {
this.iddd = iddd;
}
public Employe getSelectedemp() {
return selectedemp;
}
public void setSelectedemp(Employe selectedemp) {
this.selectedemp = selectedemp;
}
public List<Employe> getFilteredemps() {
return filteredemps;
}
public void setFilteredemps(List<Employe> filteredemps) {
this.filteredemps = filteredemps;
}
public Employe[] getSelectedemps() {
return selectedemps;
}
public void setSelectedemps(Employe[] selectedemps) {
this.selectedemps = selectedemps;
}
public void findEmpaff(){
//admin = adminfacadelocal.getAdmin(iddd);
emps = empfacadelocal.getEmpRq("");
}
public void creerEmp(){
System.out.println("azertre ");
empfacadelocal.create(emp);
saisie = true;
}
}
and here is my xhtml page
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./../resource/Template.xhtml">
<ui:define name="title">
<title> Ajout emp</title>
</ui:define>
<ui:define name="page">
<h:form id="dd">
<p:growl id="growl" showDetail="true"/>
<p:panel header="Fiche Emplyé" >
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<h:outputLabel value="Matricule Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.matEmp}"/>
<h:outputLabel value="Nom Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.nomEmp}"/>
<h:outputLabel value="Prénom Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.prenomEmp}"/>
<h:outputLabel value="Date de naissance Employé :"/>
<p:calendar disabled="#{empbean.saisie}" locale="pt" showButtonPanel="true" navigator="true" id="pttCal" value="#{empbean.emp.dateNaisEmp}"/>
<h:outputLabel value="Adresse Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.adressEmp}"/>
<h:outputLabel value="N° téléph Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{emp.emp.numTelfEmp}"/>
<h:outputLabel value="E-mail Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.emailEmp}"/>
<h:outputLabel value="N° compte Employé :"/>
<p:inputText disabled="#{empbean.saisie}" value="#{empbean.emp.numCompteEmp}"/>
<p:selectOneMenu disabled="#{empManagedBean.saisie}" value="#{empbean.emp.fonctionEmp}">
<f:selectItem itemLabel="Jardinier" itemValue="Jardinier" />
<f:selectItem itemLabel="Agent d'hygiene" itemValue="Agent d'hygiene" />
<f:selectItem itemLabel="Agent de sécurité" itemValue="Agent de sécurité" />
<f:selectItem itemLabel="Magasinier" itemValue="Magasinier" />
</p:selectOneMenu>
</h:panelGrid><br/>
<p:commandButton disabled="#{empbean.saisie}" value="Valider" update="dd" style="margin-left: 250px;" actionListener="#{empbean. }"/>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
I want call "creerEmp" method in command button's actionlistener like this #{empbean.creerEmp()} but I can't do this , please someone help me
A method for an actionlistener needs to have an ActionEvent parameter. But I think what you want is a normal action which should be fine like this:
<p:commandButton disabled="#{empbean.saisie}" value="Valider"
update="dd" style="margin-left: 250px;" action="#{empbean.creerEmp}"/>
Should work with #{empbean.creerEmp} . ActionEvent parameter is not neccesary.
You should try without composition component firstly to see if your ActionListener method works. Besides I think that You're using composition component incorrectly.

RichFaces 4 dataTable edit issue

I would like to do such table with editing like here -> http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&sample=dataTableEdit&skin=blueSky . The problem ist that, when I do changes in editPane (popupPanel) they are not remembered in private OsobaTelefon edytujOsobe. This make update impossible via JPA. I have all getters and setters and class OsobaTelefon implements Serializable.
#ManagedBean(name = "administrator")
#ViewScoped
#SessionScoped
public class Administrator implements Serializable
#EJB
private UzytkownikFacade uzytkownikFacade;
private static final long serialVersionUID = 1L;
#EJB
private OsobaFacade osobaFacade;
private Osoba osobaAdmina;
private int numerStrony = 1;
private Uzytkownik uzytkownik;
private List<Osoba> listaOsob;
private static final int CLIENT_ROWS_IN_AJAX_MODE = 10;
private int clientRows;
private int wybranaOsoba;
private OsobaTelefon edytujOsobe; //it doesn't remember the changes made in editPane
private List<OsobaTelefon> osobyITelefony;
/**
* Creates a new instance of Administrator
*/
public Administrator() {
}
public void aktualizacjaWybranejOsoby() {
this.osobyITelefony.set(this.wybranaOsoba, this.edytujOsobe);
Osoba nowaOsoba = new Osoba();
List<Telefon> nowaListaTelefonow = new ArrayList<Telefon>();
OsobaTelefon osobaTelefon = this.osobyITelefony.get(this.wybranaOsoba);
int o = this.osobyITelefony.get(this.wybranaOsoba).getIdosoby();
int of = this.osobyITelefony.get(this.wybranaOsoba).getIdtelefonu();
System.out.println("Wybrana osoba ID " + o);
System.out.println("Wybrane ID fona " + of);
boolean znalezionoOsobe = false;
Iterator<Osoba> iteOs = this.listaOsob.iterator();
while (!znalezionoOsobe && iteOs.hasNext()) {
Osoba os = iteOs.next();
if (os.getIdosoba() == o) {
znalezionoOsobe = true;
nowaOsoba.setIdosoba(os.getIdosoba());
nowaOsoba.setImie(osobaTelefon.getImie());
nowaOsoba.setNazwisko(osobaTelefon.getNazwisko());
nowaOsoba.setKodpocztowy(osobaTelefon.getKodpocztowy());
nowaOsoba.setMiejscowosc(osobaTelefon.getMiejscowosc());
nowaOsoba.setUlica(osobaTelefon.getUlica());
nowaOsoba.setUzytkownikList(os.getUzytkownikList());
Telefon nowyTelefon = new Telefon();
for (Telefon tel : os.getTelefonList()) {
if (tel.getIdtelefon() == of) {
nowyTelefon.setFkIdosoba(nowaOsoba);
nowyTelefon.setIdtelefon(of);
nowyTelefon.setNumer(this.edytujOsobe.getNumer());
System.out.println("Nr tel. "+tel.getNumer());
nowyTelefon.setOpis(this.edytujOsobe.getOpis());
nowyTelefon.setZastrzezony(this.edytujOsobe.getZastrzezony());
nowaListaTelefonow.add(nowyTelefon);
} else {
nowaListaTelefonow.add(tel);
}
}
nowaOsoba.setTelefonList(nowaListaTelefonow);
this.osobaFacade.aktualizujOsoba(nowaOsoba);
this.pobierzOsobyDoTabeli();
}
}
}
public List<Osoba> pobierzOsobyDoTabeli() {
//getting people with phone to List<OsobaTelefon> works good
}
public void switchAjaxLoading(ValueChangeEvent event) {
this.clientRows = (Boolean) event.getNewValue() ? CLIENT_ROWS_IN_AJAX_MODE : 0;
}
public void zapelnijListeTelefonow() {
//getting people phone number to List<Phone> works good
}
public void usunOsobe() {
//deleting people works good
}
}
The XHTML
<a4j:status onstart="#{rich:component('statPane')}.show()" onstop="#{rich:component('statPane')}.hide()" />
<h:form id="formProjekty">
<rich:dataTable value="#{administrator.osobyITelefony}"
var="pr"
iterationStatusVar="ite"
id="table"
rows="8" >
<rich:column width="auto">
<f:facet name="header">Imię</f:facet>
<h:outputText value="#{pr.imie}" />
</rich:column>
<rich:column>
<a4j:commandLink styleClass="no-decor"
render="editGrid"
execute="#this"
oncomplete="#{rich:component('editPane')}.show()">
<h:graphicImage library="img" name="edit.gif" alt="Edycja"/>
<a4j:param value="#{ite.index}"
assignTo="#{administrator.wybranaOsoba}" />
<f:setPropertyActionListener target="#{administrator.edytujOsobe}"
value="#{pr}" />
</a4j:commandLink>
<a4j:commandLink styleClass="no-decor"
execute="#this"
render="#none"
oncomplete="#{rich:component('confirmPane')}.show()">
<h:graphicImage library="img" name="delete.gif" alt="Usuń"/>
<a4j:param value="#{ite.index}"
assignTo="#{administrator.wybranaOsoba}" />
<f:setPropertyActionListener target="#{administrator.edytujOsobe}"
value="#{pr}" />
</a4j:commandLink>
</rich:column>
<f:facet name="footer">
<rich:dataScroller page="#{administrator.numerStrony}" />
</f:facet>
</rich:dataTable>
<a4j:jsFunction name="remove"
action="#{administrator.usunOsobe()}"
render="table"
execute="#this"
oncomplete="#{rich:component('confirmPane')}.hide();" />
<a4j:jsFunction name="edycja"
action="#{administrator.aktualizacjaWybranejOsoby()}"
render="table"
execute="#this"
oncomplete="#{rich:component('editPane')}.hide();" />
<rich:popupPanel id="statPane" autosized="true">
<h:graphicImage library="img" name="ai.gif" alt="Czekaj"/>
Proszę czekać...
</rich:popupPanel>
<rich:popupPanel id="confirmPane" autosized="true">
Czy na pewno usunać?
<a4j:commandButton value="Tak" onclick="remove();
return false;" />
<a4j:commandButton value="Nie"
onclick="#{rich:component('confirmPane')}.hide();
return false;" />
</rich:popupPanel>
<rich:popupPanel header="Edycja Osoby"
id="editPane"
domElementAttachment="parent" width="180" height="420">
<h:panelGrid columns="1" id="editGrid">
<h:panelGroup >
<h:outputText value="Imię" /><br />
<h:inputText value="#{administrator.edytujOsobe.imie}" >
<f:validateLength maximum="32" minimum="3"/>
</h:inputText>
</h:panelGroup>
</h:panelGrid><br/>
<a4j:commandButton value="Aktualizuj"
onclick="edycja(); return false;"/>
<a4j:commandButton value="Anuluj"
onclick="#{rich:component('editPane')}.hide();
return false;" />
</rich:popupPanel>
</h:form>
if you can change it then make your Aktualizuj a4j-link a little bit easier. Just try that:
<a4j:commandButton value="Aktualizuj"
onclick="#{rich:component('editPane')}.hide();"
action="#{administrator.aktualizacjaWybranejOsoby()}" render="table"/>
and put an a4j:region about your inputText and your link to send only the required values:
<rich:popupPanel header="Edycja Osoby"
id="editPane"
domElementAttachment="parent" width="180" height="420">
<a4j:region>
<h:panelGrid columns="1" id="editGrid">
<h:panelGroup >
<h:outputText value="Imię" /><br />
<h:inputText value="#{administrator.edytujOsobe.imie}" >
<f:validateLength maximum="32" minimum="3"/>
</h:inputText>
</h:panelGroup>
</h:panelGrid><br/>
<a4j:commandButtonvalue="Aktualizuj" onclick="# {rich:component('editPane')}.hide();"action="#{administrator.aktualizacjaWybranejOsoby()}" render="table"/>
<a4j:commandButton value="Anuluj"
onclick="#{rich:component('editPane')}.hide();
return false;" />
</a4j:region>
</rich:popupPanel>
I also add a render="table" to the Aktualizuj a4j:link to update the value in the datatable