I have 2 dialogs. In the 1st dialog user writes modulename and I need to pass my modulename to the second dialog and set this modulename value to bean called #{paramController.parameter.modulename}
Please, give me some ideas how to get parameter from one bean and set it to another bean?
</p:inputText>
<p:outputLabel value="Description" for="moduledescription" />
<p:inputTextarea id="moduledescription" rows="4" cols="53" autoResize="false" value="#{modulesController.selected.moduledescription}"/>
<p:outputLabel value="Database Name :" for="moduledbname" />
<p:selectOneMenu id="moduledbname" value="#{modulesController.selected.moduledbname}" style="width:342px">
<f:selectItem itemLabel="Select Connection" itemValue="" noSelectionOption="true" />
<f:selectItems var="con" value="#{sqlserverController.itemsAvailableSelectOne}" itemValue="#{sqlserverController.getSqlserver(conName)}" />
<p:ajax update="#this"/>
</p:selectOneMenu>
<p:outputLabel value="Value :" for="modulevalue" />
<p:inputTextarea id="modulevalue" rows="8" cols="53" autoResize="false" value="#{modulesController.selected.modulevalue}"/>
</p:panelGrid>
<p:commandButton actionListener="#{modulesController.create}" icon="ui-icon-check" value="Save" update="display,:ModulesListForm:datalist,:growl" oncomplete="handleSubmit(args,'ModulesCreateDialog');"/>
<p:commandButton id="btnAdd" value="Add Parameter" icon="ui-icon-plusthick" onclick="PF('dlg1').show();">
</p:commandButton>
<p:commandButton value="Cancel" icon="ui-icon-closethick" onclick="ModulesCreateDialog.hide()"/>
<br/>
</h:panelGroup>
<br/>
<h:form id="ParamForm">
<p:dialog id="AddParamDlg" header="Add Parameter" widgetVar="dlg1" minHeight="40">
<h:panelGroup id="displayParam">
<p:panelGrid columns="2">
<p:outputLabel value="Parameter Name :" for="paramname2" />
<p:inputText id="paramname2" value="#{paramController.parameter.paramname}" style="width:332px" title="#{bundleModules.CreateModulesTitle_modulename}" >
</p:inputText>
<p:outputLabel value="Default Value :" for="defaultvalue2" />
<p:inputText id="defaultvalue2" value="#{paramController.parameter.defaultvalue}" style="width:332px" title="#{bundleModules.CreateModulesTitle_modulename}"/>
<p:outputLabel value="Module Name :" for="parammodulename2" />
<p:selectOneMenu id="parammodulename2" value="#{paramController.parameter.modulename}" style="width:342px">
<f:selectItem itemLabel="Select Module Name" itemValue="" noSelectionOption="true" />
<f:selectItems var="con" value="#{modulesController.itemsAvailableSelectOne}" itemValue="#{modulesController.getModules(paramname)}" />
<p:ajax update="#this"/>
</p:selectOneMenu>
</p:panelGrid>
<p:commandButton action="#{paramController.addNewParameter}" value="Add" update="displayParam, :ModulesCreateForm:ParamForm" onclick="PF('dlg1').hide()" />
</h:panelGroup>
</p:dialog>
</h:form>
</h:form>
First of all you have a nested tag <h:form>.....<h:form> ... </h:form> </h:form>. You need to get rid of this.
SampleManagedBean1.java
#ManagedBean(name="SampleManagedBean1")
#ViewScoped
public class SampleManagedBean1 {
private String mModuleName = "";
public String getModuleName() {
return mModuleName;
}
public void setModuleName(String moduleName) {
this.mModuleName = moduleName;
}
/**
* invoke this API from UI to set value in this bean
*
* #param moduleName
*/
public void setValueOfModuleName(String moduleName) {
this.mModuleName = moduleName;
}
/**
* Invoke this API from UI to get value from this bean
*
* #return
*/
public String getValueOfModuleName() {
return mModuleName;
}
}
SampleManagedBean2.java
#ManagedBean(name="SampleManagedBean2")
#ViewScoped
public class SampleManagedBean2 {
private String mModuleName = "";
public String getModuleName() {
return mModuleName;
}
public void setModuleName(String moduleName) {
this.mModuleName = moduleName;
}
/**
* invoke this API from UI to set value in this bean
*
* #param moduleName
*/
public void setValueOfModuleName(String moduleName) {
this.mModuleName = moduleName;
}
/**
* Invoke this API from UI to get value from this bean
*
* #return
*/
public String getValueOfModuleName() {
return mModuleName;
}
}
From UI
SampleManagedBean2.setValueOfModuleName(SampleManagedBean1.getValueOfModuleName);
As I understood you have two beans, one for dialog 1 and the second for dialog2.
You can pass the "paramController.parameter" (stored in first bean) as a parameter for method (method inside second bean) which shows dialog2.
Related
I have an issue where I have a primefaces outputtext field and from the managed bean, I'm attempting to return an array type back to this field. Something is amiss in that I'm getting no return value back to my outputtext field. I will admit that I'm a bit rusty on my Java coding skills and it could be that I'm not performing something correctly within my bean method with respect to my return value.
My JSF page outputtext field
<p:panel id="horizontal" header="Conversion from Lat Long to MGRS" toggleable="true" toggleOrientation="horizontal">
<h:panelGrid columns="2" cellpadding="10" styleClass="left">
<h:outputLabel for="lat" value="Enter Latitude:" />
<p:inplace id="lat">
<p:inputText value="Latitude" />
</p:inplace>
<h:outputLabel for="long" value="Enter Longitude:" />
<p:inplace id="long">
<p:inputText value="Longitude" />
</p:inplace>
<h:outputLabel for="mgrs" value="MGRS conversion value:" />
<h:outputText id="mgrs" value="#{coordinates.MGRSCoordreturn}" />
<p:commandButton value="Submit" update="mgrs" icon="ui-icon-check" actionListener="#{coordinates.mgrsFromLatLon(lat, long)}"/>
</h:panelGrid>
</p:panel>
<h:outputLabel for="mgrs_input" value="Enter MGRS:" />
<p:inplace id="mgrs_input">
<p:inputText value="MGRS" />
</p:inplace>
<h:outputLabel for="mgrs_output" value="Lat Long conversion values:" />
<h:outputText id="mgrs_output" value="#{coordinates.latLongVReturn}" />
<p:commandButton value="Submit" update="mgrs_output" icon="ui-icon-check" actionListener="#{coordinates.latLonFromMgrs(mgrs_input)}"/>
My managed bean code:
#ManagedBean
#SessionScoped
public class Coordinates implements Serializable{
private String MGRSCoordreturn;
private Double LatLongVReturn;
public String mgrsFromLatLon(double lat, double lon){
// 37.10, -112.12
Angle latitude = Angle.fromDegrees(lat);
Angle longitude = Angle.fromDegrees(lon);
MGRSCoordreturn = MGRSCoord.fromLatLon(latitude, longitude).toString();
return MGRSCoord.fromLatLon(latitude, longitude).toString();
}
public String getMGRSCoordreturn() {
return MGRSCoordreturn;
}
public void setMGRSCoordreturn(String MGRSCoordreturn) {
this.MGRSCoordreturn = MGRSCoordreturn;
}
public double[] latLonFromMgrs(String mgrs){
MGRSCoord coord = MGRSCoord.fromString("31NAA 66021 00000");
double LatLongVReturn[] = new double[]{
coord.getLatitude().degrees,
coord.getLongitude().degrees
};
return new double[]{
coord.getLatitude().degrees,
coord.getLongitude().degrees
};
}
public Double getLatLongVReturn() {
return LatLongVReturn;
}
public void setLatLongVReturn(Double LatLongVReturn) {
this.LatLongVReturn= LatLongVReturn;
}
}
This question already has an answer here:
Ajax update/render does not work on a component which has rendered attribute
(1 answer)
Closed 6 years ago.
I'm new to JSF and Primefaces and wanted to know what the best solution is to render a component according to radio selection (hiding and showing again)? I posted my ManagedBean and my JSF-Page-Excerpt. Thanks in advance.
My JSF-Page:
<p:dialog widgetVar="komponentErstellenDialogWV" modal="true"
id="komponentErstellenDialog" header="Komponente erstellen">
<h:form>
<p:wizard flowListener="#{userWizard.onFlowProcess}">
<p:tab id="produktAuswahlTab" title="Produkt auswählen">
<p:panel>
<h:panelGrid columns="2" columnClasses="label, value">
<h:outputText value="Produkt:" />
<p:selectOneRadio id="produktAERadio"
value="#{komponenteErstellenWizardController.produktAuswahl}">
<f:selectItem itemValue="1" itemLabel="Neu erstellen" />
<f:selectItem itemValue="2" itemLabel="Aus Liste auswählen" />
<p:ajax event="click" update="produktSelect" />
</p:selectOneRadio>
<p:selectOneMenu id="produktSelect"
rendered="#{komponenteErstellenWizardController.shouldRenderProduktSelect()}"
value="#{komponenteErstellenWizardController.komponente.produkt}">
<f:selectItems
value="#{komponenteErstellenWizardController.findAllProdukt()}"
var="currentProdukt"
itemLabel="#{currentProdukt.hersteller.concat(' ').concat(currentProdukt.name)}"
itemValue="#{currentProdukt.id}" />
</p:selectOneMenu>
</h:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
</h:form>
</p:dialog>
My ManagedBean:
#ManagedBean
#SessionScoped
public class KomponenteErstellenWizardController implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
// Properties
private Komponente komponente = new Komponente();
private String produktAuswahl;
#PostConstruct
public void init() {
produktAuswahl = "1";
}
public String getProduktAuswahl() {
System.out.println("GetProduktAuswahl invoked with returning value: " + produktAuswahl);
return produktAuswahl;
}
public void setProduktAuswahl(String produktAuswahl) {
System.out.println("SetProduktAuswahl invoked with Value: " + produktAuswahl);
this.produktAuswahl = produktAuswahl;
}
public Komponente getKomponente() {
return komponente;
}
public void setKomponente(Komponente komponente) {
this.komponente = komponente;
}
// EJBs
#EJB
KomponenteFacade komponenteFacade;
#EJB
ProduktFacade produktFacade;
#EJB
ProduktArtFacade produktArtFacade;
public List<Produkt> findAllProdukt() {
return produktFacade.findAll();
}
public Boolean shouldRenderProduktSelect() {
System.out.println("Wizard Produktauswahl: " + produktAuswahl);
return "2".equals(produktAuswahl);
}
}
I updated my code according to suggestions:
Replaced faces components by primefaces components
Added a new action method "shouldRenderProduktSelect"
Still not working...
Few things..
1) Add this method to your controller:
public boolean shouldRenderSelect(){
return "2".equals(produktAuswahl);
}
2) Change the rendered attribute:
<h:selectOneMenu id="produktSelect"
rendered="#{komponenteErstellenWizardController.shouldRenderSelect()}"
3) update your html:
<p:selectOneRadio id="produktAERadio"
value="#{komponenteErstellenWizardController.produktAuswahl}">
<f:selectItem itemValue="1" itemLabel="Neu erstellen" />
<f:selectItem itemValue="2" itemLabel="Aus Liste auswählen" />
<p:ajax event="click" update="panelSelect" />
</p:selectOneRadio>
<h:panelGroup id="panelSelect">
<p:selectOneMenu id="produktSelect"
rendered="#{komponenteErstellenWizardController.shouldRenderProduktSelect()}"
...
</p:selectOneMenu>
</h:panelGroup>
The key is to wrap the selectOneMenu within and from ajax update the panelGroup, not the menu.
Good day!
I'm using JSF 2.1 Primefaces 4.0 Glassfish 3.2.1
In my Form.xhtml, I have this code.
<h:form id="modDlgFormc">
<p:dialog id="modIDc" header="Criteria Info"
showEffect="fade" hideEffect="fade" modal="true"
resizable="false" widgetVar="modDlgc" closable="false"
position="center" visible ="#{Fame.modVisiblec}">
<p:messages id="pmsgCrit" closable="true"/>
<h:panelGrid id="criteriapGrid" columns="1">
<h:panelGrid id="critLabelId" columns="2">
<p:selectOneMenu id="fieldNameId" value="#
{Fame.fieldName}" var="fieldSelect">
<f:selectItem itemLabel="Select Field Name"
itemValue="" />
<f:selectItems value="#{Fame.fieldNameMap}" />
<p:ajax event="change" update="fieldNameId
operandId" listener="#{Fame.fieldNameChange}"/>
</p:selectOneMenu>
<p:selectOneMenu id="operandId" value="#{Fame.operator}" >
<f:selectItem itemLabel="Select Operand" itemValue="" />
<f:selectItems value="#{Fame.operandMap}" />
<p:ajax event="change" update="operandId valueId"
listener="#{Fame.operandChange}" />
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid id="valueId" columns="2">
<c:if test="#{Fame.showValue == 'txt'}">
<h:outputLabel for="inputVal" value="Value : " style="font-weight: bolder"/>
<p:inputText id="inputVal" size="30" value="#{Fame.value}"/>
<c:if test="#{Fame.operator == 'Is Between'}">
<h:outputText value=""/>
<p:inputText size="30" value="#{Fame.value2}"/>
</c:if>
</c:if>
<c:if test="#{Fame.showValue == 'cal'}">
<h:outputLabel for="fromDateId" value="From : " style="font-weight: bolder"/>
<p:calendar id="fromDateId" value="#{Fame.date}" showButtonPanel="true" maxdate="#{Fame.maxDate}"/>
<c:if test="#{Fame.operator == 'Is Between'}">
<h:outputLabel for="toDateId" value="To : " style="font-weight: bolder"/>
<p:calendar id="toDateId" value="#{Fame.date2}" showButtonPanel="true" maxdate="#{Fame.maxDate}"/>
</c:if>
</c:if>
<c:if test="#{Fame.showValue == 'upload'}">
<h:outputText value=""/>
<p:commandButton value="UPLOAD" onclick="uconfirmation.show()" type="button" />
</c:if>
</h:panelGrid>
<h:panelGrid id="critBtnId" columns="4">
<p:commandButton id="addBtn" value="ADD" actionListener="#{Fame.saveCriteria}" update=":modDlgFormc:modIDc" rendered="#{empty Fame.editMode}" />
<p:commandButton value="SAVE" actionListener="#{Fame.updateCriteria}" update=":modDlgFormc:modIDc" rendered="#{not empty Fame.editMode}"/>
<p:commandButton value="CANCEL" actionListener="#{Fame.cancelCriteria}" update=":modDlgFormc" rendered="#{not empty Fame.editMode}"/>
<p:commandButton id="mCancelButtonc" value="CLOSE" update=":modDlgFormc:modIDc :wbookForm" actionListener="#{Fame.closealldialogsopen}"/>
</h:panelGrid>
<br/>
</h:panelGrid>
<center>
<h:panelGrid id="critDTable" columns="1">
<p:dataTable id="criteriaTbl" var="criteria" value="#{Fame.createdCriteria}" paginator="true" rows="5" rowIndexVar="rowIndex" paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
currentPageReportTemplate="{totalRecords} record(s) in {totalPages} page(s)">
<p:column headerText="WORKSHEET NAME">
#{criteria.wsheetName}
</p:column>
<p:column headerText="FIELD NAME">
#{criteria.fieldName}
</p:column>
<p:column headerText="OPERATOR">
#{criteria.operator}
</p:column>
<p:column headerText="VALUE">
#{criteria.value}
</p:column>
<p:column headerText="UPDATE">
<p:panelGrid>
<p:row>
<p:column style="vertical-align: top;border: none">
<p:commandButton actionListener="#{Fame.editCri(rowIndex)}" style="width:30px;text-align:center;border:none;background-color:transparent;" icon="ui-icon-pencil" update=":modDlgFormc" />
<p:commandButton actionListener="#{Fame.deleteCri(rowIndex)}" style="width:30px;text-align:center;border:none;background-color:transparent;" icon="ui-icon-close" update=":modDlgFormc" />
</p:column>
</p:row>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:panelGrid>
</center>
</p:dialog>
</h:form>
My Main code
#ManagedBean(name = "Fame")
#SessionScoped
private FameCriteriaDAOImpl fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
private ArrayList<FameCriteriaBean> createdCriteria = new ArrayList();
public void saveCriteria() {
fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
try {
if (this.validate() == true) {
//String wsheetId = fameManagementDP.getWsheetId(group_Id, workbookName);
FameCriteriaBean bean = new FameCriteriaBean();
bean.setWsheetId(this.worksheetId);
bean.setFieldName(this.fieldName);
bean.setOperator(this.operator);
bean.setValue(this.value);
String actionStr = "inserted";
fameCriteriaDAOImpl.save(bean);
}
} catch (SQLException sqlEx) {
sqlEx.printStackTrace();
error(converter.getConvertedError(sqlEx.getMessage()));
} finally {
this.initialize();
this.initializeCreatedCriteria();
this.resetCriteria();
}
}
My Bean code.
public class FameCriteriaBean {
private String wsheetName = "";
private String wsheetId = "";
private String fieldName = "";
private String operator = "";
private String value = "";
public FameCriteriaBean(){
}
/**
* #return the fieldName
*/
public String getFieldName() {
return fieldName;
}
/**
* #param fieldName the fieldName to set
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* #return the operator
*/
public String getOperator() {
return operator;
}
/**
* #param operator the operator to set
*/
public void setOperator(String operator) {
this.operator = operator;
}
/**
* #return the value
*/
public String getValue() {
return value;
}
/**
* #param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
/**
* #return the wsheetId
*/
public String getWsheetId() {
return wsheetId;
}
/**
* #param wsheetId the wsheetId to set
*/
public void setWsheetId(String wsheetId) {
this.wsheetId = wsheetId;
}
/**
* #return the wsheetName
*/
public String getWsheetName() {
return wsheetName;
}
/**
* #param wsheetName the wsheetName to set
*/
public void setWsheetName(String wsheetName) {
this.wsheetName = wsheetName;
}
}
Below is the scenario.
I choose a fieldName then the lists of operand was loaded. This is correct.
I click the button ADD, then a p:message appear that there is no operand selected. This is correct.
I had noticed that the fieldname value that I was selected when error appears was gone.
My question is how not to refresh the value of fieldNameId so that I can use it after an error is displayed in p:message.
I'm using SessionScoped for my java class because I'm using p:wizard in Form.xhtml.
Please help me to solve this.
Thank you and More Power! :)
What I did is this.
Please see updated Main class
#ManagedBean(name = "Fame")
#SessionScoped
private FameCriteriaDAOImpl fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
private ArrayList<FameCriteriaBean> createdCriteria = new ArrayList();
public void saveCriteria() {
fameCriteriaDAOImpl = new FameCriteriaDAOImpl();
if (!this.validate()) {
return;
}
try {
FameCriteriaBean bean = new FameCriteriaBean();
bean.setWsheetId(this.worksheetId);
bean.setFieldName(this.fieldName);
bean.setOperator(this.operator);
bean.setValue(this.value);
String actionStr = "inserted";
fameCriteriaDAOImpl.save(bean);
} catch (SQLException sqlEx) {
sqlEx.printStackTrace();
error(converter.getConvertedError(sqlEx.getMessage()));
} finally {
this.initialize();
this.initializeCreatedCriteria();
this.resetCriteria();
}
}
i am not able to get input text value in my bean
I have setted coverage bean as a session bean in my work flow but when i try to get value from input text it returns null
This id is in a pannel and that contains form with return false
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="form2" >
<div class="contract-menubar-internal-9x90 coverage-prod-mid-panel">
<div class="cvrg-row-div-dimension">
<p:panel id="cvrg_panel">
<h:outputLabel value="Type : " styleClass="cvrg-labels" />
<p:selectOneMenu value="" styleClass="cvrg-inputs">
<f:selectItem itemLabel="Select" itemValue="" />
<f:selectItem itemLabel="ELW" itemValue="1" />
<f:selectItem itemLabel="Maintenance" itemValue="2" />
<f:selectItem itemLabel="WT" itemValue="3" />
</p:selectOneMenu>
<h:outputLabel value="Damage Code : " styleClass="cvrg-labels" />
<p:inputText styleClass="cvrg-inputs">
</p:inputText>
<h:outputLabel value="Baumuster : " styleClass="cvrg-labels" />
<p:selectOneMenu value="" styleClass="cvrg-inputs">
<f:selectItem itemLabel="Select" itemValue="" />
<f:selectItem itemLabel="207" itemValue="1" />
<f:selectItem itemLabel="221" itemValue="2" />
</p:selectOneMenu>
<h:outputLabel value="Class : "
styleClass="cvrg-labels cvrg-class-srch-label" />
<p:selectOneMenu value="" styleClass="cvrg-inputs">
<f:selectItem itemLabel="Select" itemValue="" />
<f:selectItem itemLabel="S" itemValue="1" />
<f:selectItem itemLabel="C" itemValue="2" />
</p:selectOneMenu>
</p:panel>
<p:panel>
<div class="srch-cvrg-btn">
<p:commandButton value="Search" />
</div>
<div class="reset-cvrg-btn">
<p:commandButton value="Reset" id="reset_cvrg" update="cvrg_panel"
process="#this">
<p:resetInput target="cvrg_panel"></p:resetInput>
</p:commandButton>
</div>
</p:panel>
</div>
<p:commandButton value= "Save" styleClass="add-coverage-btn" action="#{coverageFlowManager.add}" ajax="false" > </p:commandButton>
<p:commandButton value="Add Coverage" styleClass="add-coverage-btn"
onclick="addCoverage()" />
<p:commandButton value="Save" styleClass="save-coverage-btn"
id="saveCoverage" action="#{productModel.saveCoverage}"
immediate="true" partialSubmit="true" />
<p:commandButton value="Cancel" styleClass="cancel-coverage-btn"
onclick="cancelCoverage()" />
<p:inputText id="type_inp1" value="#{coverageBean.type}" />
</div>
/**
*
*/
package com.daimler.contract.flow;
import java.util.*;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.html.HtmlInputText;
import org.springframework.security.core.context.SecurityContextHolder;
import com.daimler.contract.bean.CoverageBean;
import com.daimler.contract.bean.ProductBean;
import com.daimler.contract.entity.CoverageEntity;
import com.daimler.contract.entity.ProductEntity;
import com.daimler.contract.model.ProductModel;
import com.daimler.contract.service.CoverageService;
import com.daimler.contract.service.ProductService;
import com.mbcl.common.bean.User;
/**
* #author Jyoti
*
*/
public class CoverageFlowManager {
private CoverageService coverageService;
private ProductModel productModel;
private CoverageBean coverageBean;
HtmlInputText type;
public HtmlInputText getType() {
return type;
}
public void setType(HtmlInputText type) {
this.type = type;
}
public void setCoverageBean(CoverageBean coverageBean) {
this.coverageBean = coverageBean;
}
public static final String query = "select * from COVERAGE_MGT";
/**
* #return the coverageService
*/
public CoverageService getCoverageService() {
return coverageService;
}
/**
* #param coverageService the coverageService to set
*/
public void setCoverageService(CoverageService coverageService) {
this.coverageService = coverageService;
}
/**
* #return the productModel
*/
public ProductModel getProductModel() {
return productModel;
}
/**
* #param productModel the productModel to set
*/
public void setProductModel(ProductModel productModel) {
this.productModel = productModel;
}
public void showCMDataTable() {
String countryCode = ((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal())
.getCountryCode();
System.out.println("jyoti THROUGH DIFF");
List<CoverageEntity> cmDataTableEntity = coverageService.getCMDataTable(countryCode, query);
productModel.setCoverageEntityList(cmDataTableEntity);
//System.out.println("set in model"+pmDataModel.getPmList());
}
public String add()
{
System.out.println("Gaurav");
System.out.println(coverageBean.getType());
System.out.println(productModel.getCoverageEntityList().get(0).getId());
System.out.println(getType().getValue());
// productModel.getCoverageEntityList().add(productModel.getNewCoverage());
return null;
}
}
In your XHTML
<p:inputText id="type_inp1" value="#{coverageBean.type}" />
is mapped to
HtmlInputText type;
This is wrong. The value should map to variable of type String.
Changes:
private String type;
public String getType() {
return type;
}
public void setType(Stringtype) {
this.type = type;
}
Make above changes and try and it should work.
FYI - Use HtmlInputText for binding only. But you DO NOT need to Bind here.
I have a jsf page that I can't update the value of some checkboxes in a list of userDamain objects, in fact this is a part of my jsf page :
<h:outputText value="USER's rights list: "></h:outputText>
<p:dataTable id="userss" var="userr" value="#{userMB.userListe}">
<p:column>
<f:facet name="header"><h:outputText value="FirstName" /></f:facet>
<h:outputText value="#{userr.firstName}" />
</p:column>
<p:column>
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="Basic Usage: " />
<p:selectBooleanCheckbox value="#{userr.deletee}" immediate="true" actionListener="#{userr.deletee}" />
</h:panelGrid>
<p:commandButton value="Submit" update="display" oncomplete="dlg.show()" />
<p:dialog header="Selected Values" modal="true" showEffect="fade" hideEffect="fade" widgetVar="dlg">
<h:panelGrid columns="1" id="display">
<h:outputText value="Value 1: #{userr.deletee}" />
</h:panelGrid>
</p:dialog>
</p:column>
when I click on the boolean button 'Submit', the value of the userr.deletee is always false ( the default value ) and it's not updated anyway, I tried to use the Listner and actionListener in the booleanButton but it doesn't work, I also tried the postValidate event, so if someone has any idea of that, I would be graceful.
this is a part of my managed bean:
private List<UserDomain> userListe ;
public List<UserDomain> getUserListe() {
return this.userListe;
}
public void loadUserListe(){
this.userListe = new ArrayList<UserDomain>();
this.userListe.addAll(getUserServicee().getAll());
}
public void setUserListe(List<UserDomain> userListe) {
this.userListe = userListe;
}
a part of the userDomain bean:
...
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
#Transient
private boolean deletee;
public boolean isDeletee() {
return deletee;
}
public void setDeletee(boolean deletee) {
this.deletee = deletee;
}
I found out a solution which seems logic to me, I added to my checkbox an ajax behavior to execute a method and an attribute which called in this method to get the whole userDomain object, so on I can get the user.deletee value, here is a part of the code I m talking about:
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="Delete Right: " />
<p:selectBooleanCheckbox value="#{userr.deletee}">
<f:ajax execute="#this" listener="#{userMB.saveUserRights}" />
<f:attribute name="user" value="#{userr}" />
</p:selectBooleanCheckbox>
</h:panelGrid>
I hope this will be helpful for you