How can I use multiple value in Input text field JSF - jsf

In my xhtml there are 3 input field which calculate remaining day of two <p:calendar> dates. In next step I want to store calculated remaining day to MY DB.
<p:dataTable styleClass="vtable" editable="true" var="user"
editMode="cell" value="#{userBean.employeeList}">
<p:column styleClass="columntd" headerText="#{text['user.startedDate']}">
<p:calendar widgetVar="fromCal" value="#{vacationBean.vacation.beginDate}">
<p:ajax event="dateSelect" listener="#{dayDiffBean.fromSelected}"
update="diff" />
</p:calendar>
</p:column>
<p:column styleClass="columntd"
headerText="#{text['user.finishedDate']}">
<p:calendar widgetVar="toCal" value="#{vacationBean.vacation.endDate}">
<p:ajax event="dateSelect" listener="#{dayDiffBean.toSelected}"
update="diff" />
</p:calendar>
</p:column>
<p:column styleClass="columntd"
headerText="#{text['employee.remainingdays']}">
<p:inputText id="diff" styleClass="daysNumber"
value="#{dayDiffBean.diff}" />
</p:column>
</p:dataTable>
<h:commandButton styleClass="sndbutton1"
value="#{text['employee.send']}" action="#{vacationBean.addVac}"/>
I used value="#{dayDiffBean.diff} to get remaining day and now I also want to use my vacationbean to store remaingday to my db using like this : value="#{vacationBean.vacation.balanceDay}"
But I cant use 2 value in inputtext field like this:
<p:inputText value="dayDiffBean.diff" value1="vacationBean.vacation.balanceDay">
How can i solve this problem?
This is my vacation bean code:
#ManagedBean(name="vacationBean")
#ViewScoped
public class VacationBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Date vEndDate;
private boolean selected;
private Date vStartDate;
private Date createdDate;
private String isNobody;
Requestrelax vacation;
Employee e;
Calendar javaCalendar = null;
private short balanceDay;
#EJB
VacationLocal vacations;
#ManagedProperty(value="#{loginBean.userId}")
Integer userId;
#EJB
EmployeesLocal employees;
#PostConstruct
public void init(){
System.out.println("0");
//System.out.println("STATrtsg >> . "+ diff.getDiff());
vacation=new Requestrelax();
e=employees.getEmployee(userId);
vacation.setEmployee(e);
System.out.println("balanday is:"+balanceDay);
}
public void addVac(){
System.out.println("1");
javaCalendar = Calendar.getInstance();
Date currenDate=Calendar.getInstance().getTime();
vacation.setCreatedDate(currenDate);
vacation.setBalanceDay(balanceDay);
vacations.addEmployeeVacation(vacation);
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Employee getE() {
return e;
}
public void setE(Employee e) {
this.e = e;
}
public Requestrelax getVacation() {
return vacation;
}
public void setVacation(Requestrelax vacation) {
this.vacation = vacation;
}
public Date getvEndDate() {
return vEndDate;
}
public void setvEndDate(Date vEndDate) {
this.vEndDate = vEndDate;
}
public Date getvStartDate() {
return vStartDate;
}
public void setvStartDate(Date vStartDate) {
this.vStartDate = vStartDate;
}
public short getBalanceDay() {
return balanceDay;
}
public void setBalanceDay(short balanceDay) {
this.balanceDay = balanceDay;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getIsNobody() {
return isNobody;
}
public void setIsNobody(String isNobody) {
this.isNobody = isNobody;
}
}
And daydiffbean code :
#ManagedBean(name="dayDiffBean")
#SessionScoped
public class DayDiffBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Date from;
private Date to;
private String diff="";
private final long oneDay=1000*60*60*24;
public void fromSelected(SelectEvent event){
from=(Date) event.getObject();
calDiff();
}
public void toSelected(SelectEvent event){
to=(Date) event.getObject();
calDiff();
}
public void calDiff(){
if(from==null||to==null){
diff="N/A";
return;
}
diff=(to.getTime()-from.getTime())/oneDay+"";
}
public String getDiff() {
return diff;
}
public void setDiff(String diff) {
this.diff = diff;
}
public void setFrom(Date from) {
this.from = from;
}
public Date getFrom() {
return from;
}
public Date getTo() {
return to;
}
public void setTo(Date to) {
this.to = to;
}
}

From the code, one way to add balanceDay to your vacationBean is by passing the diff string as a parameter to addVac() method (notice action in the second line):
<h:commandButton styleClass="sndbutton1" value="#{text['employee.send']}"
action="#{vacationBean.addVac(dayDiffBean.diff)}"/>
Then, for your VacationBean.addVac():
// 'diff' is now being passed in as a parameter
public void addVac(String diff) {
System.out.println("1");
javaCalendar = Calendar.getInstance();
Date currenDate=Calendar.getInstance().getTime();
vacation.setCreatedDate(currenDate);
vacation.setBalanceDay(balanceDay);
// UPDATED
// so now you can set balanceDay
setBalanceDay(Short.parseShort(diff));
vacations.addEmployeeVacation(vacation);
}

Related

nested <p:selectOneMenu does not update value

I have two selectOneMenu one update the other, but the second one do not update its value, and still remains with the first value, despite in any code, this two variables are equal so themselves. Even the valueEventChangeListener returns the estados_eam value. Thanks guys, any help will be very appreciate. Best regards.
<h:outputText value="ESTADO:" />
<p:selectOneMenu id="estados_eam" value="#{estadosMB.clave}"
style="width:200px;" required="true">
<f:selectItem itemLabel="Seleccione un estado" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{estadosMB.estadosMap}" />
<p:ajax listener="#{municipiosMB.handleEstadosChange}" update="municipios_eam"/>
</p:selectOneMenu>
<p:message for="estados_eam" />
<h:outputText value="MUNICIPIO:" />
<p:selectOneMenu id="municipios_eam" valueChangeListener="#{municipiosMB.selectOneMenuListener}"
value="#{municipiosMB.idMunicipio}" label="Municipios"
converter="javax.faces.Integer" style="width:200px;" required="true">
<f:selectItem itemLabel="Seleccione un Municipio"
itemValue="#{null}" />
<f:selectItems value="#{municipiosMB.municipiosMap}" />
<p:ajax listener="#{municipiosMB.handleMunicipioSelectedChange}" />
</p:selectOneMenu>
<p:message for="municipios_eam" />
Bean code:
#ManagedBean(name = "municipiosMB")
#ViewScoped
public class MunicipiosMB implements Serializable {
/**
*
*/
private static final long serialVersionUID = 112312323213445L;
private static Logger logger = LoggerFactory.getLogger(MunicipiosMB.class);
#ManagedProperty(value = "#{MunicipiosService}")
private MunicipiosService municipioService;
#ManagedProperty(value = "#{estadosMB}")
private EstadosMB estadosMB;
private Map<String, String> municipiosMap;
private Municipio selectedMunicipio;
private String clave;
private Estados estado;
private Integer id;
private String nombre;
private String siglas;
private String estado_clave;
private Municipio municipio;
private Integer idMunicipio;
public void updateMunicipio(Municipio municipio) {
this.clave = municipio.getIdEstado().getClave();
this.id = municipio.getId();
this.nombre = municipio.getNombre();
this.setMunicipio(municipio);
}
public Municipio getMunicipio() {
return municipio;
}
public void setMunicipio(Municipio municipio) {
this.municipio = municipio;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
public Estados getEstado() {
return estado;
}
public void setEstado(Estados estado) {
this.estado = estado;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getSiglas() {
return siglas;
}
public void setSiglas(String siglas) {
this.siglas = siglas;
}
public Municipio getSelectedMunicipio() {
return selectedMunicipio;
}
public void setSelectedMunicipio(Municipio selectedMunicipio) {
this.selectedMunicipio = selectedMunicipio;
}
public MunicipiosService getMunicipioService() {
return municipioService;
}
public void setMunicipioService(MunicipiosService municipioService) {
this.municipioService = municipioService;
}
public Map<String, String> getMunicipiosMap() {
return municipiosMap = municipioService.getMunicipiosByClaveEstado(estadosMB.getClave());
}
public void setMunicipiosMap(Map<String, String> municipiosMap) {
this.municipiosMap = municipiosMap;
}
public EstadosMB getEstadosMB() {
return estadosMB;
}
public void setEstadosMB(EstadosMB estadosMB) {
this.estadosMB = estadosMB;
}
public Integer getIdMunicipio() {
return idMunicipio;
}
public void setIdMunicipio(Integer idMunicipio) {
this.idMunicipio = idMunicipio;
}
public void handleEstadosChange() {
try {
if (estadosMB.getClave() != null || !estadosMB.getClave().equals("77")) {
this.idMunicipio=0;
logger.info(" valor muncipio "+ this.idMunicipio);
logger.info("La clave seleccionada es "+estadosMB.getClave());
this.setMunicipiosMap(municipioService.getMunicipiosByClaveEstado(estadosMB.getClave()));
logger.info("Clave Estado Seleccionado: " + estadosMB.getClave());
logger.info("Clave Municipio Seleccionado: " + this.idMunicipio);
} else {
this.idMunicipio=0;
this.setMunicipiosMap(new HashMap<String, String>());
}
} catch (NullPointerException e) {
logger.info("EstadosMB Null");
this.setMunicipiosMap(new HashMap<String, String>());
}
}
public void handleMunicipioSelectedChange() {
logger.info("municipio seleccionado:::::: "+this.getIdMunicipio());
logger.info("municipio seleccionado2:::::: "+this.getId());
}
public Municipio selectedMunicipio() {
return municipioService.getMunicipiosById(this.getId());
}
public void selectOneMenuListener(ValueChangeEvent event) {
//This will return you the newly selected
//value as an object. You'll have to cast it.
Object newValue = event.getNewValue();
logger.info("valor nuevo"+ newValue.toString());
//The rest of your processing logic goes here...
}
}
I don't have any idea, why it is happending here...My EstadosMB
#ManagedBean(name="estadosMB")
#ViewScoped
public class EstadosMB implements Serializable {
#ManagedProperty(value="#{EstadosService}")
private EstadosService estadosService;
private String clave = "";
private Map<String,String> estadosMap;
public EstadosService getEstadosService() {
return estadosService;
}
public void setEstadosService(EstadosService estadosService) {
this.estadosService = estadosService;
}
public Map<String, String> getEstadosMap() {
return estadosMap = estadosService.getEstadosMap();
}
public void setEstadosMap(Map<String, String> estadosMap) {
this.estadosMap = estadosMap;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
}
There are two solutions:
Update the menu in the listener method in the bean by adding this line:
RequestContext.getCurrentInstance().update("municipios_eam");
Use a p:remoteCommand to update the 2nd menu, so instead of:
<p:ajax listener="#{municipiosMB.handleEstadosChange}" update="municipios_eam"/>
use:
//the remoteCommand should be placed before the first menu
<p:remoteCommand name="updateMuncipios_eam" update="municipios_eam"/>
<h:outputText value="ESTADO:" />
//some more code
<p:ajax listener="#{municipiosMB.handleEstadosChange}" oncomplete="updateMuncipios_eam()/>

p:dataTable single row selection

I have a problem selecting a row from a datatable in PrimeFaces. My selected object in the managed bean is null. For some reason, selected object from the datatable is not setting up correctly the property selectedItinerary in my managed bean.
<p:dataTable id="singleDT" value="#{travellerSearchFlightsManagedBean.searchList}" var="s" selectionMode="single" selection="#{travellerSearchFlightsManagedBean.selectedItinerary}" rowKey="#{s.iden}" >
<f:facet name="header">
Found itineraries
</f:facet>
<p:column headerText="Departure Location">
<h:outputText value="#{s.departureLocation}" />
</p:column>
<p:column headerText="Arrival Location">
<h:outputText value="#{s.arrivalLocation}" />
</p:column>
<p:column headerText="Departure Date">
<h:outputText value="#{s.departureDate}" />
</p:column>
<p:column headerText="Cost">
<h:outputText value="#{s.cost}" />
</p:column>
<p:column headerText="Stops">
<h:outputText value="#{s.stopPrint}" />
</p:column>
<f:facet name="footer">
<p:commandButton process="singleDT" value="Reserve itinerary" action="#{travellerSearchFlightsManagedBean.reserveFlight()}" />
</f:facet>
</p:dataTable>
and the managed bean is like this:
#Named(value = "travellerSearchFlightsManagedBean")
#RequestScoped
public class travellerSearchFlightsManagedBean{
#EJB
private itineraryTravellerFacadeLocal itineraryTravellerFacade;
#EJB
private itineraryFacadeLocal itineraryFacade;
#ManagedProperty(value="#{travellerLoginManagedBean}")
private travellerLoginManagedBean loginBean;
private String departureLocation;
private String arrivalLocation;
private Date departureDate;
private int departureHour;
private int departureMinute;
private int numPassengers;
private int maxStops;
private String economyOrBusiness;
private ArrayList<itineraryDTO> itinerariesList;
private ArrayList<itineraryTraveller> searchList;
private itineraryTraveller selectedItinerary;
private String stopPrint;
private static final Logger LOG = Logger.getLogger(travellerSearchFlightsManagedBean.class.getName());
public String getStopPrint() {
return stopPrint;
}
public travellerLoginManagedBean getLoginBean() {
return loginBean;
}
public void setLoginBean(travellerLoginManagedBean loginBean) {
this.loginBean = loginBean;
}
public void setStopPrint(String stopPrint) {
this.stopPrint = stopPrint;
}
public itineraryTraveller getSelectedItinerary() {
return selectedItinerary;
}
public void setSelectedItinerary(itineraryTraveller selectedItinerary) {
this.selectedItinerary = selectedItinerary;
}
public ArrayList<itineraryTraveller> getSearchList() {
return searchList;
}
public void setSearchList(ArrayList<itineraryTraveller> searchList) {
this.searchList = searchList;
}
public ArrayList<itineraryDTO> getItinerariesList() {
return itinerariesList;
}
public void setItinerariesList(ArrayList<itineraryDTO> itinerariesList) {
this.itinerariesList = itinerariesList;
}
public itineraryFacadeLocal getItineraryFacade() {
return itineraryFacade;
}
public String getEconomyOrBusiness() {
return economyOrBusiness;
}
public void setEconomyOrBusiness(String economyOrBusiness) {
this.economyOrBusiness = economyOrBusiness;
}
public void setItineraryFacade(itineraryFacadeLocal itineraryFacade) {
this.itineraryFacade = itineraryFacade;
}
public String getDepartureLocation() {
return departureLocation;
}
public void setDepartureLocation(String departureLocation) {
this.departureLocation = departureLocation;
}
public String getArrivalLocation() {
return arrivalLocation;
}
public void setArrivalLocation(String arrivalLocation) {
this.arrivalLocation = arrivalLocation;
}
public Date getDepartureDate() {
return departureDate;
}
public void setDepartureDate(Date departureDate) {
this.departureDate = departureDate;
}
public int getDepartureHour() {
return departureHour;
}
public void setDepartureHour(int departureHour) {
this.departureHour = departureHour;
}
public int getDepartureMinute() {
return departureMinute;
}
public void setDepartureMinute(int departureMinute) {
this.departureMinute = departureMinute;
}
public int getNumPassengers() {
return numPassengers;
}
public void setNumPassengers(int numPassengers) {
this.numPassengers = numPassengers;
}
public int getMaxStops() {
return maxStops;
}
public void setMaxStops(int maxStops) {
this.maxStops = maxStops;
}
public travellerSearchFlightsManagedBean() {
}
public void searchFlights(){
try{
int numPassengersEconomy=0;
int numPassengersBusiness=0;
if (economyOrBusiness.equals("Economy")){
numPassengersEconomy=numPassengers;
}else{
numPassengersBusiness=numPassengers;
}
searchList = new ArrayList<itineraryTraveller>();
itinerariesList= new ArrayList<itineraryDTO>();
int id=itineraryFacade.findItineraries(itinerariesList,departureLocation, arrivalLocation,departureDate,numPassengersEconomy, numPassengersBusiness);
searchList=itineraryFacade.listItineraries(maxStops,itinerariesList,arrivalLocation, departureLocation, numPassengersEconomy, numPassengersBusiness);
} catch(NullPointerException e) {}
}
public void reserveFlight(){
//if (){
try{
//status reserved when traveller reserves an itinerary
selectedItinerary.setStatus('r');
//set the userName from the user who reserved this itinerary before persist it in a shared among all users db
//persist the reserved itinerary in the db
itineraryTravellerFacade.create(selectedItinerary);
} catch(NullPointerException e) {}
}
}

Passing parameters in JSF and PrimeFaces

I am studying a PrimeFaces AutoComplete demo. I shortenied it from the full showcase demo. http://www.primefaces.org/showcase/ui/input/autoComplete.xhtml
AutoCompleteBean.java
#ManagedBean
public class AutoCompleteBean {
private Query query;
private List<Query> queries = new ArrayList<Query>();
#PostConstruct
public void init() {
queries.add(new Query(0, "Afterdark", "afterdark"));
queries.add(new Query(1, "Afternoon", "afternoon"));
queries.add(new Query(2, "Afterwork", "afterwork"));
queries.add(new Query(3, "Aristo", "aristo"));
}
public List<Query> completeQuery(String query) {
List<Query> filteredQueries = new ArrayList<Query>();
for (int i = 0; i < queries.size(); i++) {
Query skin = queries.get(i);
if(skin.getName().toLowerCase().contains(query)) {
filteredQueries.add(skin);
}
}
return filteredQueries;
}
public void onItemSelect(SelectEvent event) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Item Selected", event.getObject().toString()));
}
public Query getQuery() {
return query;
}
public void setQuery(Query query) {
this.query = query;
}
}
Query.java
public class Query {
private int id;
private String displayName;
private String name;
public Query() {}
public Query(int id, String displayName, String name) {
this.id = id;
this.displayName = displayName;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Override
public String toString() {
return name;
}
}
I omitted a Convert class, which I think is not that relevant.
search.xhtml
<h:form>
<p:growl id="msgs" showDetail="true" />
<h:panelGrid columns="2" cellpadding="5">
<p:autoComplete id="queryPojo" value="#{autoCompleteView.query}"
completeMethod="#{autoCompleteView.completeQuery}" var="query"
itemLabel="#{query.displayName}" itemValue="#{query}"
converter="queryConverter" forceSelection="true" />
<p:commandButton value="search" oncomplete="PF('dlg').show()"/>
</h:panelGrid>
</h:form>
I have three questions for this:
1) completeMethod="#{autoCompleteView.completeQuery}": completeQuery method is called without passing a parameter, but it's defined as completeQuery(String query). How does this work?
2) value="#{autoCompleteView.query}". Query is an object defined in AutoCompleteBean. How can this Query object take user input string as its value? Usually InputText's value is good for taking user's input, which is a String value.
3) Can I still add an attribute "action=..." to the p:autoComplete componenet?
The converter class that you omitted here plays the real game.... Lets see your questions
As you see converter class overrides 2 methods
getAsString and getAsObject
1)the value
completeMethod="#{autoCompleteView.completeQuery}
gets refactred to
autoCompleteView.completeQuery(autoCompleteView.query);
as you can find to string method in Query class.
2).as converter is defined for autocomplete it calls getAsString method to render on screen. when selected getAsObject method is called to convert string value to object(Query).
3)you can use ajax select event
<p:ajax event="select" listener="#{autoCompleteView.someMethod}">
or call a remoteCommand by onSelect attribute in p:autoComplete
<p:autoComplete id="queryPojo" value="#{autoCompleteView.query}" onSelect="someRemoteCommand();"
completeMethod="#{autoCompleteView.completeQuery}" var="query"
itemLabel="#{query.displayName}" itemValue="#{query}"
converter="queryConverter" forceSelection="true" />
<p:remoteCommand name="someRemoteCommand" update="queryPojo" actionListener="#{autoCompleteView.execute}" />

h:selectOneMenu along with f:selectItems always returns 0

Here's my XHTML code:
<h:selectOneMenu id="combo" value="#{TeamsHinzufuegenBean.selectedLeagueId}">
<f:selectItems value="#{TeamsHinzufuegenBean.leagues}"
var="league" itemValue="#{league.id}"
itemLabel="#{league.name}"/>
</h:selectOneMenu>
And my bean:
#ManagedBean(name = "TeamsHinzufuegenBean")
#ViewScoped
public class TeamsHinzufügenBean implements Serializable{
private static final long serialVersionUID = 1L;
private List<League> leagues;
private ArrayList<Team> teams = new ArrayList<Team>();
private String teamname;
private int selectedLeagueId=1;
#PostConstruct
public void init() {
leagues = Database.getInstance().getAllLeagues();
for(League l : leagues)
System.out.println(l);
}
public List<League> getLeagues() {
return leagues;
}
public void setLeagues(List<League> leagues) {
this.leagues = leagues;
}
public int getSelectedLeagueId() {
return selectedLeagueId;
}
public void setSelectedLeagueId(int selectedLeagueId) {
this.selectedLeagueId = selectedLeagueId;
}
public ArrayList<Team> getTeams() {
return teams;
}
public void setTeams(ArrayList<Team> teams) {
this.teams = teams;
}
public String getTeamname() {
return teamname;
}
public void setTeamname(String teamname) {
this.teamname = teamname;
}
}
The league-class has an attribute id but if I output the value of selectedLeagueId, it is always 0.
Check if getAllLeagues() contains objects that have an id and that it is correctly set

Primefaces p:orderList java backing list does not update

I am currently implementing a orderable list using PrimeFaces' component, embedded inside a . I was able to get the list to appear properly with my items. However, when I saved the list and submitted it back to the server, the rearranged items did not get reflected in the backing bean for some reason. Since the Primefaces showcase was able to see the changes, what am I doing wrong?
XHTML Snippet:
<h:form id="confirmDialogForm">
<p:confirmDialog id="arrangeProjDialog" widgetVar="arrangeDlg" width="600"
header="Meeting Order"
appendToBody="true" message="Drag and drop to rearrange meeting order">
<p:orderList id="arrangeProjDialogList"
value="#{adminMeetingListBean.orderProjList}"
converter="#{adminMeetingListBean.rowConverter}"
var="po"
controlsLocation="left"
styleClass="wideList"
itemLabel="#{po.projectTitle}"
itemValue="#{po}"
>
<f:facet name="caption">Proposals</f:facet>
</p:orderList>
<p:commandButton value="Save" ajax="true" process="arrangeProjDialogList #this"
actionListener="#{adminMeetingListBean.updateProposalMeetingOrder}" onclick="arrangeDlg.hide();">
</p:commandButton>
<p:button value="Cancel" onclick="arrangeDlg.hide(); return false;" />
</p:confirmDialog>
</h:form>
Backing Bean:
public void updateProposalMeetingOrder() {
if (selectedMeeting != null) {
orderProjTitles.get(0);
meetingService.updateMeetingProjSequence(orderProjList, selectedMeeting.getMeetingId());
}
}
The List is a list of POJO "ProposalOrderRow" objects. This has the definition:
public class ProposalOrderRow implements Serializable {
private static final long serialVersionUID = -5012155654584965160L;
private int dispSeq;
private int appId;
private int assignmentId;
private String refNo;
private String projectTitle;
public int getDispSeq() {
return dispSeq;
}
public void setDispSeq(int dispSeq) {
this.dispSeq = dispSeq;
}
public int getAppId() {
return appId;
}
public void setAppId(int appId) {
this.appId = appId;
}
public String getRefNo() {
return refNo;
}
public void setRefNo(String refNo) {
this.refNo = refNo;
}
public String getProjectTitle() {
return projectTitle;
}
public void setProjectTitle(String projectTitle) {
this.projectTitle = projectTitle;
}
public int getAssignmentId() {
return assignmentId;
}
public void setAssignmentId(int assignmentId) {
this.assignmentId = assignmentId;
}
}
Converter:
#FacesConverter("proposalOrderRowConverter")
public class ProposalOrderRowConverter implements Converter {
private List<ProposalOrderRow> orderRows;
#Override
public Object getAsObject(FacesContext context, UIComponent component, String newValue) {
if (newValue.isEmpty()) {
return null;
}
for (ProposalOrderRow item : orderRows) {
String refNo = item.getRefNo();
if (refNo.equals(newValue)) {
return item;
}
}
return null;
}
#Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value == null) {
return "";
}
ProposalOrderRow row = (ProposalOrderRow) value;
String output = row.getRefNo();
return output;
}
public List<ProposalOrderRow> getOrderRows() {
return orderRows;
}
public void setOrderRows(List<ProposalOrderRow> orderRows) {
this.orderRows = orderRows;
}
}
This problem is caused by appendToBody="true" in the confirm dialog. Setting it to false solved the problem.
See link here: link

Resources