JSF Complex form - Binding Error - jsf

I have a form with some inputs which has a ViewScoped *ManagedBean* behind. At the bottom of the form I have a CommandButton for saving the data. There is a datatable on the form which new items could be added by entering data to an input and clicking another CommandButton. When user filled all the inputs and added any items to the datatable he/she can click the save button. But I have some problems in controling the add button and updating the datamodel. When I set the immadiate of the button to true the value of the input won't update and when I set it to false validation error will happen for the rest of the inputs on the form!!!
Code if it helps:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./templates/master.xhtml"
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="http://www.w3.org/1999/xhtml">
<ui:define name="windowTitle">
#{lbls.registerWaggon}
</ui:define>
<ui:define name="sectionTitle">
<h:panelGroup layout="block" styleClass="sectionTitle">
<h:graphicImage library="img" name="railways.png"/>
</h:panelGroup>
</ui:define>
<ui:define name="right">
<ui:include src="templates/railwaysright.xhtml"/>
</ui:define>
<ui:define name="extraCSS">
<h:outputStylesheet library="css" name="persiancalendar.css"/>
<h:outputStylesheet library="css" name="grid.css"/>
</ui:define>
<ui:define name="extraJS">
<h:outputScript library="js" name="lib/persiancalendar.js"/>
</ui:define>
<ui:define name="content">
<h:panelGroup rendered="#{!current.hasLoggedIn()}">
<h:panelGroup layout="block" styleClass="warningBox">
<h:outputText value="#{app.youHaveNotLoggedIn}"/>
<br/>
<h:link value="#{lbls.login}" outcome="login"/>
</h:panelGroup>
</h:panelGroup>
<p:panel rendered="#{current.hasLoggedIn() and requestWaggon.isViewable()}">
<f:facet name="header">
<h:outputText value="#{lbls.registerWaggonLong}" />
</f:facet>
<h:form id="frmRequest">
<h:panelGrid columns="3" footerClass="buttons">
<h:outputText value="#{lbls.number}:"/>
<h:inputText id="number" label="#{lbls.number}" styleClass="ltr" value="#{requestWaggon.request.number}" readonly="true" />
<h:message for="number" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.requestDate}:"/>
<h:inputText styleClass="ltr" id="date" label="#{lbls.requestDate}" value="#{requestWaggon.request.date}" required="true" readonly="true">
<f:converter converterId="ir.khorasancustoms.DateConverter"/>
</h:inputText>
<h:message for="date" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.nameOfMaterialOwner}:"/>
<h:inputText id="ownerName" label="#{lbls.nameOfMaterialOwner}" value="#{requestWaggon.request.fullName}" required="true" readonly="true"/>
<h:message for="ownerName" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.companyName}:"/>
<h:inputText id="companyName" label="#{lbls.companyName}" value="#{requestWaggon.request.companyName}" required="true" readonly="true"/>
<h:message for="companyName" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.nameOfMaterial}:"/>
<h:inputText id="nameOfMaterial" label="#{lbls.nameOfMaterial}" value="#{requestWaggon.request.materialName}" required="true" readonly="true"/>
<h:message for="nameOfMaterial" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.materialWeight}:"/>
<h:panelGroup>
<h:inputText id="materialWeight" styleClass="ltr" label="#{lbls.materialWeight}" value="#{requestWaggon.request.materialWeight}" required="true" style="min-width: 0px; width: 60px" readonly="true"/>
<h:outputText value=" #{requestWaggon.request.weightUnit}"/>
</h:panelGroup>
<h:message for="materialWeight" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.senderAddress}:"/>
<h:inputText id="senderAddress" label="#{lbls.senderAddress}" value="#{requestWaggon.request.address}" required="true" style="width: 350px;" readonly="true"/>
<h:message for="senderAddress" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.receiverAddress} (#{lbls.country}):"/>
<h:outputText value="#{requestWaggon.request.country}"/>
<h:message for="country" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.station}:"/>
<h:inputText id="station" label="#{lbls.station}" value="#{requestWaggon.request.station}" required="true" readonly="true"/>
<h:message for="station" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.loadingDate}:"/>
<h:panelGroup>
<h:inputText styleClass="ltr" id="loadingDate" label="#{lbls.loadingDate}" value="#{requestWaggon.request.loadingDate}" required="true" readonly="true">
<f:converter converterId="ir.khorasancustoms.DateConverter"/>
</h:inputText>
</h:panelGroup>
<h:message for="loadingDate" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.boundryStation}:"/>
<h:outputText value="#{requestWaggon.request.bountryStation}"/>
<h:message for="boundryStation" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value=""/>
<h:outputText value=""/>
<h:outputText value=""/>
<h:outputText value="#{lbls.confirmDate}:"/>
<h:panelGroup>
<h:inputText styleClass="date ltr" id="confirmDate" label="#{lbls.confirmDate}" value="#{requestWaggon.request.confirmDate}" required="true">
<f:converter converterId="ir.khorasancustoms.DateConverter"/>
</h:inputText>
<input type="button" value="..." onclick="displayDatePicker('frmRequest:confirmDate', this);" class="datePicker"/>
</h:panelGroup>
<h:message for="confirmDate" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.confirm}:" styleClass="b"/>
<h:selectOneMenu value="#{requestWaggon.request.confirm}">
<f:selectItem/>
<f:selectItems value="#{searchRequest.allConfirms}" var="confirm" itemLabel="#{searchRequest.confirmCaption(confirm)}" itemValue="#{confirm}"/>
</h:selectOneMenu>
<h:message for="confirm" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.description}:"/>
<h:inputText id="description" label="#{lbls.description}" value="#{requestWaggon.request.confirmDescription}" required="false" style="width: 350px;"/>
<h:message for="description" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
<h:outputText value="#{lbls.waggonType}:"/>
<h:selectOneMenu id="waggonType" label="#{lbls.waggonType}" value="#{requestWaggon.request.waggonType}" required="true">
<f:selectItem/>
<f:selectItems value="#{requestWaggon.waggonTypes}"/>
<f:converter converterId="ir.khorasancustoms.CatalogValueFixedConverter"/>
</h:selectOneMenu>
<h:message for="waggonType" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>
**<h:outputText value="#{lbls.specialWaggonNumber}:"/>
<h:panelGroup>
<h:inputText id="specialWaggonNumber" label="#{lbls.specialWaggonNumber}" binding="#{requestWaggon.waggonNumberComponent}" />
<h:commandButton value="#{lbls.add}" action="#{requestWaggon.addWaggon}" immediate="true"/>
</h:panelGroup>
<h:message for="specialWaggonNumber" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>**
<h:outputText value="#{lbls.waggons}:"/>
<h:dataTable value="#{requestWaggon.waggonsDataModel}" var="waggon" columnClasses="index,,action" styleClass="grid" headerClass="title" rowClasses="two,three,one">
<h:column>
<f:facet name="header">#{lbls.index}</f:facet>
<h:outputText value="#{searchRequest.datamodel.rowIndex + 1}"/>
</h:column>
<h:column>
<f:facet name="header">#{lbls.number}</f:facet>
<h:outputText value="#{waggon.number}"/>
</h:column>
<h:column>
<f:facet name="header">#{lbls.action}</f:facet>
<h:commandLink action="delete">
<h:graphicImage styleClass="nb" alt="#{lbls.delete}" title="#{lbls.delete}" library="img" name="delete.png"/>
<f:param name="id" value="#{waggon.id}"/>
</h:commandLink>
</h:column>
</h:dataTable>
<f:facet name="footer">
<h:button outcome="searchrequest" value="#{lbls.cancel}" rendered="#{requestWaggon.id ne null}"/>
<h:commandButton action="#{requestWaggon.doNew}" value="#{lbls.new}" rendered="#{requestWaggon.request.id ne null}"/>
<h:commandButton action="#{requestWaggon.save}" value="#{lbls.ok}"/>
</f:facet>
</h:panelGrid>
<h:outputScript>
focusElement('frmRequest:confirmDate');
</h:outputScript>
</h:form>
<f:facet name="footer">
<h:messages styleClass="boxMessages" layout="table" infoClass="infoBox" warnClass="warningBox" errorClass="errorBox" fatalClass="errorBox" globalOnly="true"/>
<h:link outcome="searchrequest" value="#{lbls.searchRequestWaggon}"/>
</f:facet>
</p:panel>
<p:panel rendered="#{current.hasLoggedIn() and !requestWaggon.isViewable()}">
<h:panelGroup layout="block" styleClass="warningBox">
<h:outputText value="#{app.accessDenied}" />
</h:panelGroup>
</p:panel>
</ui:define>
</ui:composition>
bean
#ManagedBean(name = "requestWaggon")
#ViewScoped
public class RequestWaggonBean {
//<editor-fold defaultstate="collapsed" desc="FIELDS">
private Logger logger;
#ManagedProperty(value = "#{current}")
private CurrentSessionBean current;
private RequestWaggon request;
private Set<CatalogValue> weightUnits;
private Set<CatalogValue> countries;
private Set<CatalogValue> boundryStations;
private Set<CatalogValue> waggonTypes;
private Integer id;
#ManagedProperty(value = "#{searchRequest}")
private SearchRequestBean searchRequest;
private Integer newWaggonNumber;
private HtmlInputText waggonNumberComponent;
private DataModel<Waggon> waggonsDataModel;
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="CONSTRUCTORS">
public RequestWaggonBean() {
logger = LogUtil.getLogger(RequestWaggonBean.class);
request = new RequestWaggon();
ExternalContext exContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest httpRequest = (HttpServletRequest) exContext.getRequest();
String strId = httpRequest.getParameter("id");
try {
id = Integer.parseInt(strId);
} catch (Exception ex) {
logger.fatal(ex);
}
}
#PostConstruct
public void init() {
request.setDate(current.getDate());
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
ResourceBundle app = ResourceBundle.getBundle("application");
try {
//session.beginTransaction();
if (id != null) {
request = (RequestWaggon) session.get(RequestWaggon.class, id);
}
Query query = session.createQuery("from CatalogGroup as catalogGroup where catalogGroup.englishTitle = :englishTitle");
query.setParameter("englishTitle", "WeightUnit");
CatalogGroup weightUnit = (CatalogGroup) query.uniqueResult();
weightUnits = weightUnit.getValues();
query.setParameter("englishTitle", "Country");
CatalogGroup country = (CatalogGroup) query.uniqueResult();
countries = country.getValues();
query.setParameter("englishTitle", "BoundryStation");
CatalogGroup boundryStation = (CatalogGroup) query.uniqueResult();
boundryStations = boundryStation.getValues();
query.setParameter("englishTitle", "WaggonType");
CatalogGroup waggonType = (CatalogGroup) query.uniqueResult();
waggonTypes = waggonType.getValues();
//session.getTransaction().commit();
} catch (Exception ex) {
logger.fatal(ex);
Transaction tx = session.getTransaction();
if (tx.isActive()) {
tx.rollback();
}
String message = app.getString("databaseConnectionFailed");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, message));
} finally {
session.close();
}
Waggon[] arrayWaggons = new Waggon[request.getWaggons().size()];
arrayWaggons = request.getWaggons().toArray(arrayWaggons);
waggonsDataModel = new ArrayDataModel<Waggon>(arrayWaggons);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="METHODS">
public void save() {
boolean canSave = false;
String cantSaveMessage = "";
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
ResourceBundle app = ResourceBundle.getBundle("application");
try {
session.beginTransaction();
int number = 0;
if (request.getNumber() == null) {
number = RequestWaggon.nextNumber();
}
if (request.getNumber() != null || number > 0) {
if (request.getNumber() == null) {
request.setNumber(number);
canSave = isInsertable();
cantSaveMessage = app.getString("insertDenied");
} else {
canSave = isEditable();
cantSaveMessage = app.getString("editDenied");
}
if (canSave) {
session.saveOrUpdate(request);
RequestWaggonHistory history = new RequestWaggonHistory(request, current.getUser(), number > 0 ? 'I' : 'U', current.getIP());
session.save(history);
session.getTransaction().commit();
String message = app.getString("savedSuccessfully");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
} else {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, cantSaveMessage, cantSaveMessage));
}
} else {
logger.fatal("Getting next number failed!");
String message = app.getString("databaseConnectionFailed");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, message));
}
} catch (Exception ex) {
logger.fatal(ex);
Transaction tx = session.getTransaction();
if (tx.isActive()) {
tx.rollback();
}
String message = app.getString("databaseConnectionFailed");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, message));
} finally {
session.close();
}
}
public void addWaggon(ValueChangeEvent event) {
ResourceBundle app = ResourceBundle.getBundle("application");
String strNewWaggonNumber = event.getNewValue().toString();
Integer newWaggonNumber = Integer.parseInt(strNewWaggonNumber);
if (newWaggonNumber == null || newWaggonNumber <= 0) {
String message = app.getString("EnterWaggonNumber");
FacesContext.getCurrentInstance().addMessage("frmRequest:specialWaggonNumber", new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
} else {
Waggon newWaggon = new Waggon();
newWaggon.setNumber(newWaggonNumber);
request.getWaggons().add(newWaggon);
Waggon[] arrayWaggons = new Waggon[request.getWaggons().size()];
arrayWaggons = request.getWaggons().toArray(arrayWaggons);
waggonsDataModel = new ArrayDataModel<Waggon>(arrayWaggons);
}
}
public boolean isViewable() {
return current.isViewable();
}
public boolean isDeletable() {
return current.isDeletable() && request.getWaggons().isEmpty();
}
public boolean isInsertable() {
return current.isInsertable();
}
public boolean isEditable() {
return current.isEditable() && request.getConfirm() == null;
}
public void doNew() {
request = new RequestWaggon();
request.setDate(current.getDate());
}
public String delete() {
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
ResourceBundle app = ResourceBundle.getBundle("application");
try {
session.beginTransaction();
session.delete(request);
RequestWaggonHistory history = new RequestWaggonHistory(request, current.getUser(), 'D', current.getIP());
session.save(history);
session.getTransaction().commit();
searchRequest.search();
String message = app.getString("deletedSuccessfully");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
} catch (ConstraintViolationException ex) {
String message = app.getString("constraintViolation");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, message, message));
} catch (Exception ex) {
logger.fatal(ex);
Transaction tx = session.getTransaction();
if (tx.isActive()) {
tx.rollback();
}
String message = app.getString("databaseConnectionFailed");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, message, message));
} finally {
session.close();
}
return "searchrequest";
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="PROPERTIES">
public RequestWaggon getRequest() {
return request;
}
public void setRequest(RequestWaggon requestWaggon) {
this.request = requestWaggon;
}
public CurrentSessionBean getCurrent() {
return current;
}
public void setCurrent(CurrentSessionBean current) {
this.current = current;
}
public Set<CatalogValue> getWeightUnits() {
return weightUnits;
}
public void setWeightUnits(Set<CatalogValue> weightUnits) {
this.weightUnits = weightUnits;
}
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
public Set<CatalogValue> getCountries() {
return countries;
}
public void setCountries(Set<CatalogValue> countries) {
this.countries = countries;
}
public Set<CatalogValue> getBoundryStations() {
return boundryStations;
}
public void setBoundryStations(Set<CatalogValue> boundryStations) {
this.boundryStations = boundryStations;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public SearchRequestBean getSearchRequest() {
return searchRequest;
}
public void setSearchRequest(SearchRequestBean searchRequest) {
this.searchRequest = searchRequest;
}
public Set<CatalogValue> getWaggonTypes() {
return waggonTypes;
}
public void setWaggonTypes(Set<CatalogValue> waggonTypes) {
this.waggonTypes = waggonTypes;
}
public Integer getNewWaggonNumber() {
return newWaggonNumber;
}
public void setNewWaggonNumber(Integer newWaggonNumber) {
this.newWaggonNumber = newWaggonNumber;
}
public DataModel<Waggon> getWaggonsDataModel() {
return waggonsDataModel;
}
public void setWaggonsDataModel(DataModel<Waggon> waggonsDataModel) {
this.waggonsDataModel = waggonsDataModel;
}
public HtmlInputText getWaggonNumberComponent() {
return waggonNumberComponent;
}
public void setWaggonNumberComponent(HtmlInputText waggonNumberComponent) {
this.waggonNumberComponent = waggonNumberComponent;
}
//</editor-fold>
}

The h:commandButton submits the whole form and all elements will be validated. You can use ajax to do a partial submit. Try the following:
Give your datatable an id value. So you can reference it from your commandButton:
<h:panelGroup id="tableWrapper">
<h:datatable id="mytable" value="#{requestWaggon.waggonsDataModel}" ..>
...
</h:datatable>
</h:panelGroup>
Then put an <f:ajax> inside your commandButton. The render and execute attributes must contain the id of your datatable; immediate=true is not needed:
<h:commandButton value="#{lbls.add}" action="#{requestWaggon.addWaggon}">
<f:ajax render="tableWrapper" execute="mytable"/>
</h:commandButton>

Related

CommandButton in Dialog containing Picklist doesn't fire action method

the problem I have is that the command button in my dialog doesn't fire the action method in the controller. No logger outputs for the example method "greet". Can anybody look over please and give me hints? What am I doing wrong?
My JSF-Page:
<!DOCTYPE HTML>
<html lang="en" 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.org/ui" xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions">
<f:view id="bestellungLieferantView">
<f:metadata>
<f:event type="preRenderView"
listener="#{camundaTaskForm.startTaskForm()}" />
</f:metadata>
<h:head>
<title>Paket zusammenstellen</title>
</h:head>
<h:body>
<h:form id="bestellungLieferantForm">
<p:dialog id="komponentenAuswahlDialog"
header="Komponenten auswählen" widgetVar="komponentenAuswahlDialog"
modal="true" height="auto" width="auto">
<p:pickList id="komponenteAuswahlPickList"
value="#{bestellungLieferantController.komponentenDualListModel}"
var="komponente" itemLabel="#{komponente.serienNummer}"
converter="entityConverter"
itemValue="#{komponente}" showSourceFilter="true"
showTargetFilter="true">
<f:facet name="sourceCaption">Quelle</f:facet>
<f:facet name="targetCaption">Ziel</f:facet>
</p:pickList>
<p:commandButton process="#this"
action="#{bestellungLieferantController.greet}"
id="auswahlSpeichern" value="Auswahl speichern"
oncomplete="PF('komponentenAuswahlDialog').hide();" />
</p:dialog>
<h:panelGrid id="paketInformationPG" columns="2" border="1">
<f:facet name="header">
<h:outputText value="Paket zusammenstellen" />
</f:facet>
<h:outputLabel value="Kunde:" />
<h:outputText value="#{processVariables['kunde']}" />
<h:outputLabel value="Betriebssystem:" />
<h:outputText value="Platzhalter" />
<h:outputLabel value="Benutzer:" />
<h:outputText value="#{processVariables['benutzerName']}" />
</h:panelGrid>
<h:panelGrid id="komponentenZusammenstellungPG" columns="2"
border="1">
<f:facet name="header">
<h:panelGrid columns="2">
<h:outputText value="Komponenten" />
<p:commandButton id="auswahlKomponenteButton"
action="#{bestellungLieferantController.createAvailableKomponentDualListModel()}"
type="button" onclick="PF('komponentenAuswahlDialog').show();"
value="+" />
</h:panelGrid>
</f:facet>
<p:dataTable id="komponenteTable" widgetVar="komponenteTable"
var="komponente"
value="#{bestellungLieferantController.komponentenList}">
<p:column>
<f:facet name="header">Typ</f:facet>
<h:outputText value="#{komponente.produkt.typ.name}" />
</p:column>
<p:column>
<f:facet name="header">Bezeichnung</f:facet>
<h:outputText value="#{komponente.produkt.name}" />
</p:column>
<p:column>
<f:facet name="header">SN</f:facet>
<h:outputText value="#{komponente.serienNummer}" />
</p:column>
<p:column headerText="Kaufdatum">
<f:facet name="header">Kaufdatum</f:facet>
<h:outputText value="#{komponente.bestellDatum}" />
</p:column>
<p:column>
<f:facet name="header">Aktion</f:facet>
<p:commandLink value="Bearbeiten" />
<p:commandLink value="Enfernen" />
</p:column>
</p:dataTable>
</h:panelGrid>
</h:form>
</h:body>
</f:view>
</html>
My Bean:
#ManagedBean(name="bestellungLieferantController")
#SessionScoped
public class BestellungLieferantController implements Serializable{
/**
*
*/
private static final long serialVersionUID = 2862985625231368306L;
#EJB
private BestellungFacade bestellungFacade;
#EJB
private PaketFacade paketFacade;
#EJB
private KomponenteFacade komponenteFacade;
#EJB
private BetriebssystemFacade betriebssystemFacade;
// Komponent-List with added komponent items
private List<Komponente> komponentenList = new ArrayList<Komponente>();
private DualListModel<Komponente> komponentenDualListModel;
private static final Logger logger = Logger.getLogger(BestellungLieferantController.class);
public DualListModel<Komponente> getKomponentenDualListModel() {
return komponentenDualListModel;
}
public void setKomponentenDualListModel(DualListModel<Komponente> komponentenDualListModel) {
this.komponentenDualListModel = komponentenDualListModel;
}
public List<Komponente> getKomponentenList() {
logger.info("KomponenList-Size: " + this.komponentenList.size());
return komponentenList;
}
public void setKomponentenList(List<Komponente> komponentenList) {
logger.info("Setting a new KomponentenList...");
this.komponentenList = komponentenList;
}
public void greet(){
logger.info("Greet Method Invoked!");
}
/**
* Gets the actual Model with the distinct source and
* #param targetList
* #return
*/
#PostConstruct
public void createAvailableKomponentDualListModel(){
// Logger
logger.info("CreateAvailableKomponentDualList invoked!");
List<Komponente> sourceKomponenteList = this.komponenteFacade.getAllAvailableKomponente();
List<Komponente> sourceKomponenteDistinctList = new ArrayList<Komponente>();
if (this.komponentenList.size() != 0){
for(Komponente k : sourceKomponenteList){
if (!komponentenList.contains(k)){
sourceKomponenteDistinctList.add(k);
}
}
} else {
sourceKomponenteDistinctList = sourceKomponenteList;
}
// komponentenDualListModel.setSource(sourceKomponenteDistinctList);
// komponentenDualListModel.setTarget(komponentenList);
this.setKomponentenDualListModel(new DualListModel<Komponente>());
this.getKomponentenDualListModel().setSource(sourceKomponenteDistinctList);
this.getKomponentenDualListModel().setTarget(this.komponentenList);
}
public void putSelectionIntoKomponenteList(){
logger.info("PutSelectionIntoKomponentList");
logger.info("KOMPONENTELIST: " + komponentenDualListModel.getTarget());
this.komponentenList = this.komponentenDualListModel.getTarget();
}
}
My Converter:
#FacesConverter(value = "entityConverter")
public class EntityConverter implements Converter {
// Checking the converter
private static final Logger logger = Logger.getLogger(EntityConverter.class);
private static Map<Object, String> entities = new WeakHashMap<Object, String>();
#Override
public String getAsString(FacesContext context, UIComponent component, Object entity) {
synchronized (entities) {
logger.info("[Converter] GetAsString: " + ", Class:" + entity.getClass() + ", Component-ID: " + component.getId());
if (!entities.containsKey(entity)) {
String uuid = UUID.randomUUID().toString();
entities.put(entity, uuid);
return uuid;
} else {
return entities.get(entity);
}
}
}
#Override
public Object getAsObject(FacesContext context, UIComponent component, String uuid) {
logger.info("[Converter] GetAsString: " + ", UUID:" + uuid + ", Component-ID: " + component.getId());
for (Entry<Object, String> entry : entities.entrySet()) {
if (entry.getValue().equals(uuid)) {
return entry.getKey();
}
}
//return uuid;
return null;
}
}
you need actionListener attribute instead of action in your p:commandbutton tag. and Also use #ViewScoped instead of #SessionScoped in your backing bean. and add ajax="false" in p:commandButton

Managed bean never gets instantiated

In my JSF I have a dataTable. Each row (showing a user) has a form that takes his ID as only parameter. The problem is that the associated backing bean never gets called (neither the methods follow/unfollow nor the constructor and the PostConstruct annotated method).
searchUserResult.xhtml
<h:dataTable value="#{searchUserMB.searchResult}" var="user"
rowClasses="tdUser"
rendered="#{not empty searchUserMB.searchResult}">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.Username}" />
</f:facet>
<h:outputText value="#{user.username}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.Name}" />
</f:facet>
<h:outputText value="#{user.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.Surname}" />
</f:facet>
<h:outputText value="#{user.surname}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.Action}" />
</f:facet>
<h:form rendered="#{userMB.user.isFollower(user.id)}">
<h:commandButton value="#{bundle.Unfollow}"
action="#{followMB.unfollow}">
<f:param name="followerId" value="#{user.id}" />
</h:commandButton>
</h:form>
<h:form rendered="#{not userMB.user.isFollower(user.id)}">
<h:commandButton value="#{bundle.Follow}"
action="#{followMB.follow}">
<f:param name="followerId" value="#{user.id}" />
</h:commandButton>
</h:form>
</h:column>
</h:dataTable>
FollowMB
#ManagedBean
#RequestScoped
public class FollowMB {
#EJB
private DBObjectRemote db;
#ManagedProperty(value="#{userMB}")
private UserMB userMB;
#ManagedProperty(value="#{param.followerId}")
private int followerId;
public FollowMB() {
System.out.println("I'm in the constructor");
}
#PostConstruct
public void init() {
System.out.println("I'm in the PostConstruct");
}
public String follow() {
// DB stuff
}
public String unfollow() {
// DB stuff
}
public UserMB getUserMB() {
return userMB;
}
public void setUserMB(UserMB userMB) {
this.userMB = userMB;
}
public int getFollowerId() {
return followerId;
}
public void setFollowerId(int followerId) {
this.followerId = followerId;
}
}
Generated HTML:
<form id="j_idt15:0:j_idt30" name="j_idt15:0:j_idt30" method="post"
action="/myApp/private/searchUserResult.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt15:0:j_idt30" value="j_idt15:0:j_idt30">
<script type="text/javascript"
src="/myApp/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script>
<input type="submit" name="j_idt15:0:j_idt30:j_idt31" value="Follow"
onclick="mojarra.jsfcljs(document.getElementById('j_idt15:0:j_idt30'),
{'j_idt15:0:j_idt30:j_idt31':'j_idt15:0:j_idt30:j_idt31','followerId':'502'},'');
return false">
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0"
value="-6780758405072567889:8862631453580026176" autocomplete="off">
main.jsf
<h:form>
<h:inputText value="#{searchUserMB.searchTerm}" required="true"/><br/>
<h:commandButton action="#{searchUserMB.search}" />
</h:form>
SearchUserMB
#ManagedBean
#RequestScoped
public class SearchUserMB {
#EJB
private DBObjectRemote db;
private String searchTerm;
private List<User> searchResult;
public SearchUserMB() {}
public String search() {
searchResult = db.searchUser(searchTerm);
return "searchUserResult";
}
public String getSearchTerm() {
return searchTerm;
}
public void setSearchTerm(String searchTerm) {
this.searchTerm = searchTerm;
}
public List<User> getSearchResult() {
return searchResult;
}
public void setSearchResult(List<User> searchResult) {
this.searchResult = searchResult;
}
}

f:setPropertyActionListener not invoked in p:dataTable

I followed Primefaces DataGrid showcase for doing my datatable. I want an edit imagebutton for each row of datatable and after onclick I want to show an edit dialog form.
The problem is that setSelectedChannel method not fired on commandlink click , so I have this error when dialog try to access to selecteChannel fields:
javax.el.PropertyNotFoundException: /WEB-INF/includes/channels.xhtml #54,91 value="#{channelBean.selectedChannel.name}": Target Unreachable, 'selectedChannel' returned null
So this is my xhtml include page:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:form id="channelForm">
<p:dataTable var="channel" value="#{channelBean.channels}">
<p:column headerText="Name">
<h:outputText value="#{channel.name}" />
</p:column>
<p:column headerText="Field 1">
<h:outputText value="#{channel.field1}" />
</p:column>
<p:column headerText="Field 2">
<h:outputText value="#{channel.field2}" />
</p:column>
<p:column headerText="ApiWriteKey">
<h:outputText value="#{channel.apiWriteKey}" />
</p:column>
<p:column headerText="Edit">
<p:commandLink update=":channelForm:panelEditCh" oncomplete="PF('dlg2').show();" title="Edit">
<h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
<f:setPropertyActionListener value="#{channel}" target="#{channelBean.selectedChannel}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="dialogNewChannel" header="New Channel" widgetVar="dlg1" modal="false" >
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<p:outputLabel for="channelName" value="Channel name:" />
<p:inputText id="channelName" value="#{channelBean.name}" />
<p:outputLabel for="channelDesc" value="Channel description:" />
<p:inputText id="channelDesc" value="#{channelBean.description}" />
<p:outputLabel for="channelField1" value="Channel field 1:" />
<p:inputText id="channelField1" value="#{channelBean.field1}" />
<p:outputLabel for="channelField2" value="Channel field 2:" />
<p:inputText id="channelField2" value="#{channelBean.field2}" />
</h:panelGrid>
<p:commandButton id="saveButton" value="Save" action="#{channelBean.saveChannel}" update="channelForm" ajax="true" />
<p:commandButton value="Cancel" type="button" action="#{channelBean.resetForm}" onclick="PF('dlg1').hide();" />
</p:dialog>
<p:dialog id="dialogEditChannel" header="Edit Channel" widgetVar="dlg2" modal="false" >
<h:panelGrid id="panelEditCh" columns="2" style="margin-bottom:10px" cellpadding="5">
<p:outputLabel for="channelNameEdit" value="Channel name:" />
<p:inputText id="channelNameEdit" value="#{channelBean.selectedChannel.name}" />
<p:outputLabel for="channelDescEdit" value="Channel description:" />
<p:inputText id="channelDescEdit" value="#{channelBean.selectedChannel.description}" />
<p:outputLabel for="channelField1Edit" value="Channel field 1:" />
<p:inputText id="channelField1Edit" value="#{channelBean.selectedChannel.field1}" />
<p:outputLabel for="channelField2Edit" value="Channel field 2:" />
<p:inputText id="channelField2Edit" value="#{channelBean.selectedChannel.field2}" />
</h:panelGrid>
<p:commandButton id="saveButtonEdit" value="Save" action="#{channelBean.saveChannel}" update="channelForm" ajax="true" />
<p:commandButton value="Cancel" type="button" action="#{channelBean.resetForm}" onclick="PF('dlg2').hide();" />
</p:dialog>
<p:spacer></p:spacer>
<p:spacer></p:spacer>
<p:commandButton value="New Channel" type="button" onclick="PF('dlg1').show();" />
<!-- <p:blockUI block="dialogNewChannel" trigger="saveButton">
<p:graphicImage name="images/ajax-loader-large.gif"/>
</p:blockUI>
-->
</h:form>
and ManagedBean :
#ManagedBean
#ViewScoped
public class ChannelBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1668407926998690759L;
private String idChannel;
private String apiWriteKey;
private String name;
private String description;
private String userId;
private String field1;
private String field2;
private Channel selectedChannel;
private List<Channel> channels= new ArrayList<Channel>() ;
#PostConstruct
public void populateChannelList(){
refreshList();
}
public void refreshList(){
HttpSession session = Util.getSession();
int idUser=-1;
if(session!=null &&session.getAttribute("idUser")!=null){
idUser=(int) session.getAttribute("idUser");
}
channels=ChannelDAO.getChannels(idUser);
}
public void saveChannel(){
....
}
public void resetForm(){
idChannel="";
apiWriteKey="";
name="";
description="";
userId="";
field1="";
field2="";
}
public String getIdChannel() {
return idChannel;
}
public void setIdChannel(String idChannel) {
this.idChannel = idChannel;
}
public String getApiWriteKey() {
return apiWriteKey;
}
public void setApiWriteKey(String apiWriteKey) {
this.apiWriteKey = apiWriteKey;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getField1() {
return field1;
}
public void setField1(String field1) {
this.field1 = field1;
}
public String getField2() {
return field2;
}
public void setField2(String field2) {
this.field2 = field2;
}
public List<Channel> getChannels() {
return channels;
}
public void setChannels(List<Channel> channels) {
this.channels = channels;
}
public Channel getSelectedChannel() {
return selectedChannel;
}
public void setSelectedChannel(Channel selectedChannel) {
this.selectedChannel = selectedChannel;
}
}

Primefaces actionbutton called several times

I've been strugling with an issue I can't find the way to solve it and I can't find anything related on the web.
I'm using Netbeans with Primefaces to develop a JSF web app.
Everything works fine except that sometimes the call to the actionlisteners is being done several times.
For example this is my JSF page with primefaces:
<h:body>
<ui:composition template="home.xhtml">
<ui:define name="content">
<h2>Administración de alertas SMS</h2>
<p:panel id="display">
<p:selectBooleanCheckbox itemLabel="Enviar alertas SMS" value="#{smsConfigBean.alertsEnabled}"/>
<p>
<h:outputText value="Mensaje de Texto: " /><br /><br />
<p:inputTextarea rows="5" cols="50" counterTemplate="{0} caracteres restantes." counter="counter" maxlength="160" value="#{smsConfigBean.smsMessage}" id="smsMessage"/>
<br />
<h:outputText id="counter" />
</p>
<p>
<h:outputText value="Dispositivo de envio SMS: " />
<p:selectOneRadio id="options" value="#{smsConfigBean.usePhone}">
<f:selectItem itemLabel="Modem USB" itemValue="false" />
<f:selectItem itemLabel="Telefono Android" itemValue="true" />
</p:selectOneRadio>
</p>
<br />
<p:tabView id="tabView">
<p:tab id="tab1" title="Modem USB">
<h:panelGrid id="modemGrid" columns="2" cellpadding="4">
<h:outputText value="Puerto: " />
<p:inputText id="port" value="#{smsConfigBean.port}"/>
<h:outputText value="Bit Rate (Opcional): " />
<p:inputText id="bitRate" value="#{smsConfigBean.bitRate}"/>
<h:outputText value="Nombre de modem (Opcional): " />
<p:inputText id="modemName" value="#{smsConfigBean.modemName}"/>
<h:outputText value="PIN: " />
<p:inputText id="pin" value="#{smsConfigBean.modemPin}"/>
<h:outputText value="Centro de Mensajes: " />
<p:inputText id="smsc" value="#{smsConfigBean.SMSC}"/>
</h:panelGrid>
</p:tab>
<p:tab id="tab2" title="Telefono Android">
<h:panelGrid id="phoneGrid" columns="2" cellpadding="4">
<h:outputText value="Path ADB:" />
<p:inputText id="adbPath" value="#{smsConfigBean.adbPath}"/>
<h:outputText value="Directorio de Configuracion:" />
<p:inputText id="configPath" value="#{smsConfigBean.configPath}"/>
<h:outputText value="Modo de conexion " />
<p:selectOneRadio id="connectOptions" value="#{smsConfigBean.useWifi}">
<f:selectItem itemLabel="USB" itemValue="false"/>
<f:selectItem itemLabel="WiFi" itemValue="true" />
</p:selectOneRadio>
<h:outputText value="Direccion IP (Solo para WiFi): " />
<p:inputText id="ipDir" value="#{smsConfigBean.ipDir}"/>
</h:panelGrid>
</p:tab>
</p:tabView>
</p:panel>
<br />
<p:commandButton id="saveSmsAlerts" value="Guardar" update="messages" action="#{smsConfigBean.saveChanges}" actionListener="#{smsConfigBean.saveChanges}"/>
</ui:define>
</ui:composition>
</h:body>
And this is my backend bean:
package Beans;
import helpers.Global; import javax.faces.bean.ManagedBean; import
javax.faces.bean.SessionScoped;
#ManagedBean #SessionScoped public class SmsConfigBean {
private Boolean alertsEnabled;
private Boolean usePhone;
private Boolean useWifi;
private String port;
private int bitRate;
private String modemName;
private String modemPin;
private String SMSC;
private String adbPath;
private String configPath;
private String ipDir;
private String smsMessage;
public SmsConfigBean() {
alertsEnabled = Global.getAlertsEnabled();
port = Global.getPort();
bitRate = Global.getBitRate();
modemName = Global.getModemName();
modemPin = Global.getModemPin();
SMSC = Global.getSMSC();
usePhone = Global.getUsePhone();
adbPath = Global.getAdbPath();
configPath = Global.getConfigPath();
useWifi = Global.getUseWifi();
ipDir = Global.getIpDir();
smsMessage = Global.getSmsMessage();
}
public Boolean getAlertsEnabled() {
return alertsEnabled;
}
public void setAlertsEnabled(Boolean alertsEnabled) {
this.alertsEnabled = alertsEnabled;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public int getBitRate() {
return bitRate;
}
public void setBitRate(int bitRate) {
this.bitRate = bitRate;
}
public String getModemName() {
return modemName;
}
public void setModemName(String modemName) {
this.modemName = modemName;
}
public String getModemPin() {
return modemPin;
}
public void setModemPin(String modemPin) {
this.modemPin = modemPin;
}
public String getSMSC() {
return SMSC;
}
public void setSMSC(String SMSC) {
this.SMSC = SMSC;
}
public Boolean getUsePhone() {
return usePhone;
}
public void setUsePhone(Boolean usePhone) {
this.usePhone = usePhone;
}
public String getAdbPath() {
return adbPath;
}
public void setAdbPath(String adbPath) {
this.adbPath = adbPath;
}
public String getConfigPath() {
return configPath;
}
public void setConfigPath(String configPath) {
this.configPath = configPath;
}
public Boolean getUseWifi() {
return useWifi;
}
public void setUseWifi(Boolean useWifi) {
this.useWifi = useWifi;
}
public String getIpDir() {
return ipDir;
}
public void setIpDir(String ipDir) {
this.ipDir = ipDir;
}
public String getSmsMessage() {
return smsMessage;
}
public void setSmsMessage(String smsMessage) {
this.smsMessage = smsMessage;
}
public void saveChanges(){
Global.setSmsMessage(smsMessage);
Global.setIpDir(ipDir);
Global.setUseWifi(useWifi);
Global.setConfigPath(configPath);
Global.setAdbPath(adbPath);
Global.setUsePhone(usePhone);
Global.setSMSC(SMSC);
Global.setModemPin(modemPin);
Global.setModemName(modemName);
Global.setBitRate(bitRate);
Global.setPort(port);
Global.setAlertsEnabled(alertsEnabled);
Global.sendInfoResponseMessage("Cambios guardados con exito");
}
}
The problem is that when saving the changes of this form by hitting the commandButton 'saveSmsAlerts' the call is being made twice. Resulting in the growl message to be shown twice too.
(You won't see the growl component because it was defined in the template)
This happens also in another page that I did for the same app that uploads a file using fileuploader. The file is uploaded 4 times!!
I'm using chrome to test the application and netbeans to develop it.
You should remove one of action or actionListener attribute.
<p:commandButton id="saveSmsAlerts" value="Guardar" update="messages" action="#{smsConfigBean.saveChanges}"/>
if you remove action attribute you should change the action method signature
<p:commandButton id="saveSmsAlerts" value="Guardar" update="messages" actionListener="#{smsConfigBean.saveChanges}"/>
Like this
public void saveChanges(ActionEvent e){
...
}
here is the difference between action and actionListener
Differences between action and actionListener

Ignore the set method of a value in p:inputText until the form is submitted

Anyone know of a way to assign the value of a p:inputText so it displays correctly in a dialog window but only update a change in the value from a commandButton action instead of a dynamic set method of the value in the backing bean. Have the users add a step and it shows up in the ring then they can click the individual steps, but I want them to be able to update the step info only through the update step button, not by just changing the field and closing the dialog? Built-in method would be prefer, I know I can code around, but trying not to.
Thanks in advance....
<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
<p:dialog modal="true" widgetVar="statusDialog" header="Status"
draggable="false" closable="false">
<p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
</p:dialog>
<h:form id="form">
<p:panel header="Setup System" >
<p:selectOneMenu value="#{groups.selected_sys_code}" id="systems" rendered="#{utility.systemDD}">
<f:selectItem itemLabel="Choose System" itemValue="" />
<f:selectItems value="#{supportBean.access_system_codes}"/>
<p:ajax listener="#{groups.valueChanged}" event="valueChange" render="systemForm" execute="#all"/>
</p:selectOneMenu>
<h:panelGroup id="systemForm" >
<p:panel id="panel" header="Step Details">
<p:messages id="msgs"/>
<h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
<p:panelGrid columns="2" styleClass="veaGrid">
<h:outputLabel for="name" value="Name:"/>
<p:inputText id="name" value="#{setup.name}" label="Name" required="true"/>
<h:outputLabel for="desc" value="Description:"/>
<p:inputText id="desc" value="#{setup.description}" label="Description" required="true"/>
<h:outputLabel for="email" value="Email For Group Responsible:"/>
<p:inputText id="email" value="#{setup.emailResp}" label="Email" required="true"/>
<h:outputLabel for="process" value="Process:"/>
<p:inputText id="process" value="#{setup.process}" label="Process" required="true"/>
</p:panelGrid>
</h:panelGrid>
<p:commandButton value="Add Step" update="panel,stepsRing" actionListener="#{setup.setSteps}" process="#form" >
</p:commandButton>
<p:commandButton value="Submit All Steps" actionListener="setup.submitSteps">
</p:commandButton>
</p:panel>
</h:panelGroup>
<h:panelGroup id="stepsRing" >
<p:panel header="Steps">
<p:ring id="basic" value="#{setup.steps}" var="step" >
<p:column>
<p:outputPanel/>
<p:outputPanel style="text-align:center;" layout="block" >
Step #{step.sequence}
<br/>
<p:commandButton update=":form:detail" title="View" oncomplete="dlg.show()" value="Details" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
</p:outputPanel>
</p:column>
</p:ring>
</p:panel>
</h:panelGroup>
<p:dialog id="dialog" widgetVar="dlg" showEffect="fade" hideEffect="fade" modal="true" width="300" >
<p:outputPanel id="detail" style="text-align:center;" layout="block">
<h:panelGrid columns="2" cellpadding="5" rendered="#{not empty setup.selectedStep}">
<f:facet name="header">
Step #{setup.selectedStep.sequence}
</f:facet>
<h:outputText value="Name: " />
<p:inputText id="name2" value="#{setup.selectedStep.name}" />
<h:outputText value="Description: " />
<p:inputText id="desc2" value="#{setup.selectedStep.description}" />
<h:outputText value="Email: " />
<p:inputText id="email2" value="#{setup.selectedStep.emailResp}"/>
<h:outputText value="Process: " />
<p:inputText id="process2" value="#{setup.selectedStep.process}"/>
<p:commandButton update="stepsRing" actionListener="#{setup.removeStep}" title="Remove" oncomplete="dlg.hide()" value="Remove Step" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
<p:commandButton update="stepsRing" process="#form" actionListener="#{setup.updateStep}" title="Update" value="Update Step" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</p:panel>
</h:form>
BackingBean
#ManagedBean(name="setup")
#ViewScoped
public class WorkStepSetupSystemBean implements Serializable{
private WorkSetup step;
public ArrayList <WorkSetup> steps=new ArrayList <WorkSetup> ();
private WorkSetup ws;
private String system="test1";
private String emailResp;
private String process;
private String name;
private String description;
private Integer sequence;
private String email2;
private String process2;
private String name2;
private String desc2;
private WorkSetup selectedStep;
public WorkStepSetupSystemBean(){
}
public String getDesc2() {
return desc2;
}
public String getEmail2() {
return email2;
}
public String getName2() {
return name2;
}
public String getProcess2() {
return process2;
}
public WorkSetup getSelectedStep() {
return selectedStep;
}
public ArrayList<WorkSetup> getSteps() {
return steps;
}
public WorkSetup getStep() {
return step;
}
public void setSteps(ActionEvent event) {
step= new WorkSetup();
step.setName(name);
step.setEmailResp(emailResp);
step.setDescription(description);
step.setSystem(system);
step.setProcess(process);
step.setSequence(steps.size()+1);
steps.add(step);
return;
}
public void setStep(ArrayList<WorkSetup> steps) {
this.steps = steps;
}
public Integer getSequence() {
return sequence;
}
public String getDescription() {
return description;
}
public String getEmailResp() {
return emailResp;
}
public String getName() {
return name;
}
public String getProcess() {
return process;
}
public String getSystem() {
return system;
}
public void setDescription(String description) {
this.description = description;
}
public void setEmailResp(String emailResp) {
this.emailResp = emailResp;
}
public void setName(String name) {
this.name = name;
}
public void setProcess(String process) {
this.process = process;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
public void setSystem(String system) {
this.system = system;
}
public void setDesc2(String desc2) {
this.desc2 = desc2;
}
public void setEmail2(String email2) {
this.email2 = email2;
}
public void setName2(String name2) {
this.name2 = name2;
}
public void setProcess2(String process2) {
this.process2 = process2;
}
public void setSelectedStep(WorkSetup selectedStep) {
this.selectedStep = selectedStep;
}
public void removeStep(ActionEvent event) {
steps.remove(steps.indexOf(this.selectedStep));
for(int i=0;i<steps.size();i++){
steps.get(i).setSequence(i+1);
}
}
public void updateStep(ActionEvent event) {
step=steps.get(steps.indexOf(this.selectedStep));
step.setName(name2);
step.setEmailResp(email2);
step.setDescription(desc2);
step.setSystem(system);
}
}
Ended up using
<p:inplace id="inplaceName" >
<p:inputText id="name2" value="#{setup.selectedStep.name}" />
<p:tooltip for="inplaceName" value="Click here to edit"/>
</p:inplace>
without the AJAX option

Resources