I have a problem, well when I save my object to the DB it works fine, but when i want to retrieve it from the DB doesn't work, I'm using selectItemsConverter by Omnifaces
I have my Object "Modelo" which has two other objects inside, which are "Marca" and "Gama"
These are my Java entities (the toString() is for Omnifaces):
Modelo:
private Marca marca;
private Gama gama;
getters and setters...
#Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
Marca:
getters and setters...
#Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
Gama:
getters and setters...
#Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
Well and this is my managedBean
ModeloBean
#ManagedBean
#ViewScoped
public class ModeloBean {
private Modelo modelo = new Modelo();
getters and setters ...
//This is for call the DB to retrieve the value, and works fine, but i cant show the preselected value to the xhtml
public void leer(Modelo mo) throws Exception {
ModeloDAO dao = new ModeloDAO();
try {
this.init();
this.modelo = dao.leer(mo);
} catch (Exception e) {
throw e;
} finally {
dao = null;
}
}
This is my xhtml Page
I have a dialog which I used it for save and update an object
<p:dialog id="dlgDatos" widgetVar="wdlgDatos" modal="true" appendToBody="true" header="#{modeloBean.accion}" draggable="false" resizable="false">
<h:form>
<h:panelGrid columns="2">
<p:outputLabel value="Marca" />
<p:selectOneMenu value="#{modeloBean.modelo.marca}" converter="omnifaces.SelectItemsConverter" filter="true" filterMatchMode="startsWith" required="true">
<f:selectItem itemLabel="Seleccione" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{marcaBean.lstMarcasVigentes}" var="marca" itemLabel="#{marca.nombre}" itemValue="#{marca}" />
</p:selectOneMenu>
<p:outputLabel value="Gama" />
<p:selectOneMenu value="#{modeloBean.modelo.gama}" converter="omnifaces.SelectItemsConverter" filter="true" filterMatchMode="startsWith" required="true">
<f:selectItem itemLabel="Seleccione" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{gamaBean.lstGamasVigentes}" var="gama" itemLabel="#{gama.nombre}" itemValue="#{gama}" />
</p:selectOneMenu>
<p:outputLabel for="txtNombre" value="Modelo" />
<p:column>
<p:inputTextarea id="txtNombre" value="#{modeloBean.modelo.nombre}" />
<p:watermark for="txtNombre" value="Para registrar varios modelos, sepárelos por comas (,)" />
</p:column>
<p:outputLabel value="Vigencia" rendered="#{modeloBean.accion eq 'Modificar'}"/>
<p:selectBooleanCheckbox value="#{modeloBean.modelo.vigencia}" rendered="#{modeloBean.accion eq 'Modificar'}"/>
<p:commandButton value="#{modeloBean.accion}" actionListener="#{modeloBean.operar()}" oncomplete="PF('wdlgDatos').hide(); PF('wdtLista').clearFilters();" update=":frmLista:dtLista, :msj"/>
<p:commandButton value="Cancelar" immediate="true" onclick="PF('wdlgDatos').hide();"/>
</h:panelGrid>
</h:form>
</p:dialog>
The selectOneMenu works fine for save, but for update only retrieve me the Strings value and not the preselected value of my comboBoxes
This is the dialog which only retrieve the String value of "105" cause is a String and my boolean value for the checkbox "Vigencia" but not my comboBoxes values. Where am I wrong?
I solved it adding this to my entites (hashCode and equals)
#Override
public int hashCode() {
int hash = 5;
hash = 83 * hash + this.codigo;
return hash;
}
#Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Modelo other = (Modelo) obj;
if (this.codigo != other.codigo) {
return false;
}
return true;
}
Related
below is my jsf code,
<h:outputText value="SP Id" styleClass="required"/>
<h:selectOneMenu style="padding-left:60px;" class="input" id="spid" required="true" requiredMessage="Select SP Id"
value="#{applicationController.spid}">
<p:ajax listener="#{applicationController.onFromChange()}"
update="fromnames" />
<f:selectItem itemValue="" itemLabel="--Select--" />
<f:selectItems value="#{applicationController.spids}"></f:selectItems>
</h:selectOneMenu>
<h:message for="spid" class="hmsg" />
<h:outputText value="Sp Name" class="left1"/>
<h:inputText class="input" id="fromnames"
value="#{applicationController.spname}" />
<h:message for="fromnames" />
backing bean code is(method),
public void onFromChange() {
if (spid != null && !spid.equals("")) {
int spId = Integer.parseInt(spid);
spname = baseService.getSalesPersonById(spId);
} else {
}
}
//setter-getters
public String getSpname() {
return spname;
}
public void setSpname(String spname) {
this.spname = spname;
}
public List<Integer> getSpids() {
return spids;
}
public void setSpids(List<Integer> spids) {
this.spids = spids;
}
from above code every thing works fine.
problem:if i select f:selectItems values, relating values(spname)
are displaying. after selecting f:selectItem spname should set to null but it's not setting to null, instead of that previous values are displayed.
change jsf code as below,
<h:selectOneMenu style="padding-left:60px;" class="input" id="spid" required="true" requiredMessage="Select SP Id"
value="#{applicationController.spid}">
<p:ajax listener="#{applicationController.onFromChange()}"
update="myForm1" event="change" process="#this"/>
<f:selectItem itemValue="0" itemLabel="--Select--" noSelectionOption="false" />
<f:selectItems value="#{applicationController.spids}"></f:selectItems>
</h:selectOneMenu>
<h:message for="spid" class="hmsg" />
and modify backing bean method as,
public void onFromChange() {
if (spid != null && !spid.equals("")) {
try{
int spId = Integer.parseInt(spid);
spname = baseService.getSalesPersonById(spId);
}
catch(Exception exception){
spname = null;
}
} else {
spname = null;
}
}
This is about a JSF + JPA application.
Bill and BillItem are two entities with Bilateral OneToMany relationship with cascadeType=all in a JPA application.
When the use clicks a new Bill, a new Bill object is create. User then fill properties of a BillItem like name and quantity and click the Add to Bill button, so that BillItem is added to the list of BillItems in the Bill Object. User interface is updated with Datatable linked to the bill.billItems.
After adding one or more billItems to the Bill, the user click the settle button where the bill object is persisted.
The issue is that it is not possible to remove billItem from the list. Always the first item is removed. How can I get the required billItem from the list ?
Code of Bill Entity
#Entity
public class Bill implements Serializable {
#OneToMany(mappedBy = "bill", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
List<BillItem> billItems = new ArrayList<>();
...
..
}
Code for BillItem Entity
#Entity
public class BillItem implements Serializable {
#ManyToOne
Bill bill;
....
...
#Override
public boolean equals(Object object) {
if (!(object instanceof BillItem)) {
return false;
}
BillItem other = (BillItem) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
}
Code for JSF Managed Bean
#Named
#SessionScoped
public class SaleController implements Serializable {
private BilledBill bill;
BillItem billItem;
public void removeItem(){
if(removingItem==null){
UtilityController.addErrorMessage("Select one to remove");
return;
}
getBill().getBillItems().remove(removingItem);
}
public String newSaleBill() {
fillAvailableStocks();
listBillsToSettle();
clearBill();
clearBillItem();
printPreview = false;
bill = null;
return "sale";
}
public void settle() {
....
saveBill();
UtilityController.addSuccessMessage("Successfully Billed");
}
public void addItem() {
......
getBill().getBillItems().add(billItem);
calTotal();
clearBillItem();
}
public void saveBill() {
bill.setBillType(BillType.SaleToCustomer);
getBill().setInstitution(getSessionController().getInstitution());
getBill().setDepartment(getSessionController().getDepartment());
getBill().setStaff(getSessionController().getLoggedUser().getStaff());
getBill().setDeptId(getBillNumberBean().departmentBillNumberGenerator(getSessionController().getDepartment(), BillType.SaleToCustomer, BillNumberSuffix.SB));
getBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.SaleToCustomer, BillNumberSuffix.SB));
getBill().setRepId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getLoggedUser().getStaff(), BillType.SaleToCustomer, BillNumberSuffix.SB));
getBill().setToInstitution(getSessionController().getInstitution());
getBill().setToDepartment(getSessionController().getDepartment());
getBill().setCreatedAt(new Date());
getBill().setBillDate(Calendar.getInstance().getTime());
getBill().setCreater(getSessionController().getLoggedUser());
getBillFacade().create(getBill());
}
public BilledBill getBill() {
if (bill == null) {
bill = new BilledBill();
getBillFacade().create(bill);
}
return bill;
}
public BillItem getBillItem() {
if (billItem == null) {
billItem = new BillItem();
}
return billItem;
}
public void setBillItem(BillItem BillItem) {
this.billItem = BillItem;
}
public BillItem getRemovingItem() {
return removingItem;
}
public void setRemovingItem(BillItem removingItem) {
this.removingItem = removingItem;
}
}
JSF Page
<h:panelGrid columns="5">
<h:outputLabel value="Select Item"/>
<h:outputLabel value="Qty (kg)"/>
<h:outputLabel value="Rate"/>
<h:outputLabel value="Value"/>
<h:outputLabel value=""/>
<p:selectOneMenu id="acItem" converter="stockCon" value="#{saleController.billItem.stock}" var="vt" >
<f:selectItems value="#{saleController.availableStock}" var="ast" itemValue="#{ast}" itemLabel="#{ast.itemBatch.item.name}" ></f:selectItems>
<p:column >
<h:outputLabel value="#{vt.itemBatch.item.name}" ></h:outputLabel>
</p:column>
<p:column >
<h:outputLabel value="#{vt.stock}" ></h:outputLabel>
</p:column>
</p:selectOneMenu>
<p:inputText id="txtQty" value="#{saleController.billItem.qty}" styleClass="normalNoBox" >
<f:ajax event="blur" execute="acItem txtQty " render="" listener="#{saleController.calValueFromRate()}"></f:ajax>
</p:inputText>
<p:inputText id="txtRate" value="#{saleController.billItem.netRate}" styleClass="normalNoBox" >
<f:ajax event="blur" execute="acItem txtQty txtRate" render="lblVal" listener="#{saleController.calValueFromRate()}" ></f:ajax>
</p:inputText>
<h:outputLabel id="lblVal" value="#{saleController.billItem.netValue}" styleClass="normalNoBox" ></h:outputLabel>
<p:commandButton value="Add Item" action="#{saleController.addItem}" ajax="false" />
</h:panelGrid>
<p:panelGrid columns="2">
</p:panelGrid>
</h:panelGrid>
<p:dataTable var="ph" value="#{saleController.bill.billItems}" id="itemList">
<f:facet name="header">
<h:outputLabel value="Sale Items" ></h:outputLabel>
</f:facet>
<p:column headerText="Item Name" style="width:30%">
<h:outputLabel id="item" value="#{ph.item.name}" >
</h:outputLabel>
</p:column>
<p:column headerText="Qty (kg)" style="width:20%">
<h:outputLabel id="qty" value="#{ph.qty}" >
</h:outputLabel>
</p:column>
<p:column headerText="Rate" style="width:20%">
<h:outputLabel id="itemRate" value="#{ph.grossRate}" >
</h:outputLabel>
</p:column>
<p:column headerText="Value" style="width:20%">
<h:outputLabel id="itemVal" value="#{ph.grossValue}" >
</h:outputLabel>
</p:column>
<p:column headerText="Remove" style="width:20%">
<h:commandButton value="Remove" action="#{saleController.removeItem()}" >
<f:setPropertyActionListener target="#{saleController.removingItem}" value="#{ph}" ></f:setPropertyActionListener>
</h:commandButton>
</p:column>
</p:dataTable>
</p:panel>
When I print the selected item in the console , it is always returned as null
here is the method that create the SelectItem in my ManagedBean:
public List<String> getlisteMatricule() throws HibernateException
{
List<String> matricules = new ArrayList<String>();
for (Vehicule v : vehiculedao.getAll())
{
matricules.add(v.getMatricule());
System.out.println(v.getMatricule());
}
return matricules ;
}
public List<SelectItem> getAllMatricules()
{
List<SelectItem> options = new ArrayList<SelectItem>();
List<String> listMatricules = getlisteMatricule();
for (String mat : listMatricules)
{
options.add(new SelectItem(mat));
System.out.println("items = " + new SelectItem(mat));
}
return options ;
}
And here is my variables in my model which contain the getter and the setters and the constructor:
public class Program
{
private int id_progf;
private int nbrHeure;
private float montantGlobal;
private String commentaire;
private int cin_mon;
private String matricule;
private int cin_cand;
///gettersand setters
.... }
The methode that bring the variables from the database (List)
#Override
public Vehicule getMatricule(String matricule) {
Session session = HibernateUtil.currentSession();
Vehicule v=(Vehicule)session.get(Vehicule.class, matricule);
return v;
}
And finally my xhtml file, it contains the form:
<h:panelGrid columns="2" >
<h:outputText value="Moniteur :" />
<h:selectOneMenu id="listeNomPrenom" title="Nom et Prenom" value="{#programMB.np}">
<f:selectItems value="#{moniteurMB.allNomPrenom}" />
</h:selectOneMenu>
<h:outputText value="Vehicule :" />
<h:selectOneMenu id="ListeMatricules" title="Matricules" value="{#programMB.program.matricule}">
<f:selectItems value="#{vehiculeMB.allMatricules}" />
</h:selectOneMenu>
<h:outputText value="Nombre heures:" />
<p:inputText value="#{programMB.program.nbrHeure}" />
</h:panelGrid>
<p:commandButton value="Save" action="#{programMB.ajouterProg}" />
In the first look, I saw the problem is in the value attribute of both of your selectOneMenu bellow:
<h:selectOneMenu id="listeNomPrenom" title="Nom et Prenom" value="{#programMB.np}">
<f:selectItems value="#{moniteurMB.allNomPrenom}" />
</h:selectOneMenu>
and:
<h:selectOneMenu id="ListeMatricules" title="Matricules" value="{#programMB.program.matricule}">
<f:selectItems value="#{vehiculeMB.allMatricules}" />
</h:selectOneMenu>
In both of them you just putted # in the wrong place. change value="{#programMB.np}" to value="#{programMB.np}" and value="{#programMB.program.matricule}" to value="#{programMB.program.matricule}" and it should work for you!
In my application (RichFaces 4.1) I have an extendedDataTable, in my backing bean I need to track the selected rows. I achieve this with the following code:
JSF:
<rich:extendedDataTable id="freie"
selectionMode="multipleKeyboardFree"
selection="#{myBean.tableSelection}"
...
<a4j:ajax execute="#this" event="selectionchange"
listener="#{myBean.tableSelection}"
render="indicatorPanel" />
Java:
UIExtendedDataTable dataTable= (UIExtendedDataTable) event.getComponent();
Object originalKey= dataTable.getRowKey();
_tableSelectedEntries.clear();
for (Object selectionKey: _tableSelection) {
dataTable.setRowKey(selectionKey);
if (dataTable.isRowAvailable()) {
_tableSelectedEntries.add((Entry) dataTable.getRowData());
}
}
dataTable.setRowKey(originalKey);
This works fine, as long as the table is not filtered. I use the standard RichFaces way to filter the table:
<rich:column sortBy="#{mitarbeiter.vorname}"
filterValue="#{mitarbeiterFilterBean.firstNameFilter}"
filterExpression="#{fn:containsIgnoreCase(mitarbeiter.vorname, mitarbeiterFilterBean.firstNameFilter)}">
When the table is filtered and I select for instance the first row, I get the rowKey for the first row of the unfiltered table in the backing bean. How can I get the rowData of the selected row when my table is filtered?
I think my code works the same way as in the showcase.
I could solve my problem by making my filter bean SessionScoped. I also don't bind the currently selected rows to my backing bean anymore. I get the selected rows using:
public void tableSelection (AjaxBehaviorEvent event) {
UIExtendedDataTable dataTable= (UIExtendedDataTable) event.getComponent();
for (Object selectionKey: dataTable.getSelection()) {
It could also be achieved using rowKeyVar to get the correct row index.
Maybe you have overlooked something because I tried it and it works.
I copied the source for selectableTable and added the filter method from filterTable
Example usage: To get the selected item/items data just use a get method for selected items list
Source code (xhtml):
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Richfaces Welcome Page</title>
</h:head>
<h:body>
<h:panelGrid columns="2">
<h:form>
<fieldset style="margin-bottom: 10px;">
<legend>
<h:outputText value="Selection Mode " />
</legend>
<h:selectOneRadio value="#{exTableSelect.selectionMode}">
<f:selectItem itemLabel="Single" itemValue="single" />
<f:selectItem itemLabel="Multiple" itemValue="multiple" />
<f:selectItem itemLabel="Multiple Keyboard-free" itemValue="multipleKeyboardFree" />
<a4j:ajax render="table, res" />
</h:selectOneRadio>
</fieldset>
<rich:extendedDataTable value="#{exTableSelect.inventoryItems}" var="car"
selection="#{exTableSelect.selection}" id="table" style="height:300px; width:500px;"
selectionMode="#{exTableSelect.selectionMode}">
<a4j:ajax execute="#form" event="selectionchange" listener="#{exTableSelect.selectionListener}"
render=":res" />
<f:facet name="header">
<h:outputText value="Cars marketplace" />
</f:facet>
<rich:column filterValue="#{exTableSelect.vendorFilter}"
filterExpression="#{fn:containsIgnoreCase(car.vendor, exTableSelect.vendorFilter)}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Vendor " />
<h:inputText value="#{exTableSelect.vendorFilter}">
<a4j:ajax render="table" execute="#this" event="change" />
</h:inputText>
</h:panelGroup>
</f:facet>
<h:outputText value="#{car.vendor}" />
</rich:column>
</rich:extendedDataTable>
</h:form>
<a4j:outputPanel id="res">
<rich:panel header="Selected Rows:" rendered="#{not empty exTableSelect.selectionItems}">
<rich:list type="unordered" value="#{exTableSelect.selectionItems}" var="sel">
<h:outputText value="#{sel.vendor} - #{sel.model} - #{sel.price}" />
</rich:list>
</rich:panel>
</a4j:outputPanel>
</h:panelGrid>
</h:body>
</html>
Managed Bean:
public class ExTableSelect {
private String selectionMode = "multiple";
private Collection<Object> selection;
private List<InventoryItem> inventoryItems;
private List<InventoryItem> selectionItems = new ArrayList<InventoryItem>();
private String vendorFilter;
public void selectionListener(AjaxBehaviorEvent event) {
UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();
Object originalKey = dataTable.getRowKey();
selectionItems.clear();
for (Object selectionKey : selection) {
dataTable.setRowKey(selectionKey);
if (dataTable.isRowAvailable()) {
selectionItems.add((InventoryItem) dataTable.getRowData());
}
}
dataTable.setRowKey(originalKey);
}
public Filter<?> getFilterVendor() {
return new Filter<InventoryItem>() {
public boolean accept(InventoryItem t) {
String vendor = getVendorFilter();
if (vendor == null || vendor.length() == 0 || vendor.equals(t.getVendor())) {
return true;
}
return false;
}
};
}
#PostConstruct
public void addInventory(){
InventoryItem i = new InventoryItem();
i.setVendor("A");
InventoryItem i2 = new InventoryItem();
i2.setVendor("AB");
InventoryItem i3 = new InventoryItem();
i3.setVendor("AC");
InventoryItem i4= new InventoryItem();
i4.setVendor("E");
InventoryItem i5 = new InventoryItem();
i5.setVendor("F");
InventoryItem i6 = new InventoryItem();
i6.setVendor("G");
InventoryItem i7 = new InventoryItem();
i7.setVendor("H");
InventoryItem i8 = new InventoryItem();
i8.setVendor("I");
InventoryItem i9 = new InventoryItem();
i9.setVendor("J");
inventoryItems= new ArrayList<InventoryItem>();
inventoryItems.add(i);
inventoryItems.add(i2);
inventoryItems.add(i3);
inventoryItems.add(i4);
inventoryItems.add(i5);
inventoryItems.add(i6);
inventoryItems.add(i7);
inventoryItems.add(i8);
inventoryItems.add(i9);
}
public Collection<Object> getSelection() {
return selection;
}
public void setSelection(Collection<Object> selection) {
this.selection = selection;
}
public List<InventoryItem> getInventoryItems() {
return inventoryItems;
}
public void setInventoryItems(List<InventoryItem> inventoryItems) {
this.inventoryItems = inventoryItems;
}
public InventoryItem getSelectionItem() {
if (selectionItems == null || selectionItems.isEmpty()) {
return null;
}
return selectionItems.get(0);
}
public List<InventoryItem> getSelectionItems() {
return selectionItems;
}
public void setSelectionItems(List<InventoryItem> selectionItems) {
this.selectionItems = selectionItems;
}
public String getSelectionMode() {
return selectionMode;
}
public void setSelectionMode(String selectionMode) {
this.selectionMode = selectionMode;
}
public void setVendorFilter(String vendorFilter) {
this.vendorFilter = vendorFilter;
}
public String getVendorFilter() {
return vendorFilter;
}
}
I am working on an application using JSF 2.1 and PrimeFaces 3.2, server Tomcat 7. Right now, I am working on form to register new users. The problem is in converter.
I use few standard fields and two of them are passwords. I have custom data type for password, so I want to use converter to convert String data from field to Password variable in a bean. Primefaces forms use AJAX after submit, and there is probably the problem. If I fill in the form completely, without validation errors, everything works fine. But if there is a validaton error and no converter error (I check for the password length in the converter), whole form stops working at all. I have to refresh page to have it working again.
Here are some sources:
Password class:
public class Password {
public static final short MIN_LENGTH = 5;
private String text;
private String hash;
public Password(String text) {
this.text = text;
this.hash = Hasher.sha512(text);
}
/**
* Get password instance with known hash only
* #param hash SHA-512 hash
* #return Password instance
*/
public static Password getFromHash(String hash) {
Password password = new Password(null);
password.hash = hash;
return password;
}
#Override
public int hashCode() {
return hash.hashCode();
}
#Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Password other = (Password) obj;
if ((this.hash == null) ? (other.hash != null) : !this.hash.equals(other.hash)) {
return false;
}
return true;
}
#Override
public String toString() {
return hash;
}
/**
* #return the text
*/
public String getText() {
return text;
}
}
Password converter:
#FacesConverter(forClass = Password.class)
public class PasswordConverter implements Converter {
#Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
String text = (String) value;
if (text.length() >= Password.MIN_LENGTH) {
return new Password(text);
}
FacesMessage msg = new FacesMessage(Texter.get("forms/forms", "shortPassword").replace("%limit%", String.valueOf(Password.MIN_LENGTH)));
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(msg);
}
#Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
try {
Password password = (Password) value;
return password.getText();
} catch (Exception ex) {
throw new ConverterException(ex);
}
}
}
The form in facelet:
<h:form id="registration">
<p:panelGrid columns="3">
<h:outputLabel value="#{commonTxt.email}:" for="email" />
<p:inputText id="email" value="#{userRegistrationForm.email}" required="true" requiredMessage="#{formsTxt.msgEmpty}">
<f:validator validatorId="email" />
<f:validator validatorId="unique" />
<f:attribute name="entity" value="SystemUser" />
<f:attribute name="field" value="email" />
<f:attribute name="uniqueMessage" value="#{formsTxt.nonUniqueEmail}" />
</p:inputText>
<p:message for="email" />
<h:outputLabel value="#{usersTxt.password}:" for="password" />
<p:password id="password" value="#{userRegistrationForm.password}" binding="#{password}" autocomplete="off" feedback="true" weakLabel="#{formsTxt.passwordWeak}" goodLabel="#{formsTxt.passwordGood}" strongLabel="#{formsTxt.passwordStrong}" promptLabel="#{formsTxt.passwordPrompt}" />
<p:message for="password" />
<h:outputLabel value="#{usersTxt.passwordCheck}:" for="passwordCheck" />
<p:password id="passwordCheck" value="#{userRegistrationForm.passwordCheck}" binding="#{passwordCheckInput}" autocomplete="off">
<f:validator validatorId="match" />
<f:attribute name="matchAgainst" value="#{password}" />
<f:attribute name="matchMessage" value="#{formsTxt.passwordMismatch}" />
</p:password>
<p:message for="passwordCheck" />
<p:column /><p:column /><p:column />
<h:outputLabel value="#{usersTxt.name}:" for="name" />
<p:inputText id="name" value="#{userRegistrationForm.name}" maxlength="255" required="true" requiredMessage="#{formsTxt.msgEmpty}" />
<p:message for="name" />
<f:facet name="footer">
<p:commandButton value="#{usersTxt.register}" action="#{userRegistrationForm.register()}" update="registration" />
</f:facet>
</p:panelGrid>
</h:form>
I won't post code of the bean #{userRegistrationForm}, there are two Passwords properties with getters and setters.
Any help leading to solution of my problem appreciated. Thanks in advance.
Solved! I just used FacesContext.getCurrentInstance().isValidationFailed() to see if the validation failed or not. In case of failure, the converter now returns null (the conversion won't be done), in other case the converter will return proper object. And the form works fine with the conversion working.