including selectOneMenu in datatable - jsf-2

i have created datatable with four selectOneMenu in it
whenever i change the first selectOneMenu values of second selectOneMenu need to be populated on the same row and again on the selection of second selectOneMenu third needs to populate
i had done this by passing row number value to each selectOneMenu (with intention which particular selectOneMenu user must has clicked on) but whenever i pass the value with f:param i am getting null value on the controller but same can be printed with outputText on datatable
please guide
<t:dataTable id="insertTaskDataTable" border="1"
value="#{insertTask.taskList}" var="taskInfo" rowIndexVar="row"
iterationStatusVar="it">
<t:column>
<h:inputHidden id="id" value="#{row}"/>
</t:column>
<t:column>
<f:facet name="header">#{bundle['GROUP_HEADER']}</f:facet>
<h:selectOneMenu id="taskGroup" value="#{taskInfo.groupList.comboValue}" onchange="document.getElementById('addTask:filterButton').click();">
<f:param name="idTaskGroup" value="#{row}"/>
<t:outputText name="id" value="#{row}"/>
<f:selectItems value="#{taskInfo.groupList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['ACTIVITY_HEADER']}</f:facet>
<h:selectOneMenu id="taskActivity" value="#{taskInfo.activityList.comboValue}">
<f:ajax render="taskSubActivity" listener="#{insertTask.handleActivityChange}"></f:ajax>
<f:selectItems value="#{taskInfo.activityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['SUBACTIVITY_HEADER']}</f:facet>
<h:selectOneMenu id="taskSubActivity" value="#{taskInfo.subActivityList.comboValue}">
<f:selectItems value="#{taskInfo.subActivityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['COMPLEXTIY_HEADER']}</f:facet>
<h:selectOneMenu id="taskComplexity" value="#{taskInfo.complexityList.comboValue}">
<f:selectItems value="#{taskInfo.complexityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['BENCHMARK_EFFORT_HEADER']}</f:facet>
<t:inputText value="#{taskInfo.benchMarkHrs}" />
<t:outputLabel value="hrs"/>
<t:inputText value="#{taskInfo.benchMarkMin}" />
<t:outputLabel value="min"/>
</t:column>
<t:column>
<f:facet name="header">#{bundle['DESCRIPTION_HEADER']}</f:facet>
<t:inputText value="#{taskInfo.taskdescription}" />
</t:column>
</t:dataTable>
</t:div>
<a4j:commandButton id="filterButton" style="visibility:hidden;display:none" action="#{insertTask.handleGroupChange}" render="insertTaskDataTable" />

Hi Guys i got solution
here it is,
<t:dataTable id="insertTaskDataTable" border="1"
value="#{insertTask.taskList}" var="taskInfo" rowIndexVar="row"
iterationStatusVar="it" rendered="#{insertTask.taskList[0] != null}" >
<t:column>
<f:facet name="header">#{bundle['GROUP_HEADER']}</f:facet>
<h:selectOneMenu id="taskGroup" value="#{taskInfo.groupList.comboValue}" onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:groupButton').click();">
<f:selectItems value="#{taskInfo.groupList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['CATEGORY_HEADER']}</f:facet>
<h:selectOneMenu id="taskCategory" value="#{taskInfo.categoryList.comboValue}" onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:categoryButton').click();">
<f:selectItems value="#{taskInfo.categoryList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['ACTIVITY_HEADER']}</f:facet>
<h:selectOneMenu id="taskActivity" value="#{taskInfo.activityList.comboValue}" onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:activityButton').click();">
<f:selectItems value="#{taskInfo.activityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['SUBACTIVITY_HEADER']}</f:facet>
<h:selectOneMenu id="taskSubActivity" value="#{taskInfo.subActivityList.comboValue}" onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:subActivityButton').click();">
<f:selectItems value="#{taskInfo.subActivityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['COMPLEXTIY_HEADER']}</f:facet>
<h:selectOneMenu id="taskComplexity" value="#{taskInfo.complexityList.comboValue}">
<f:selectItems value="#{taskInfo.complexityList.comboValues}" />
</h:selectOneMenu>
</t:column>
<t:column>
<f:facet name="header">#{bundle['BENCHMARK_EFFORT_HEADER']}</f:facet>
<t:outputText value="#{taskInfo.benchMarkHrs}" style="height: 10px; width: 50px;" />
<t:outputLabel value=" hrs"/>
<t:outputText value="#{taskInfo.benchMarkMin}" style="height: 10px; width: 50px;" />
<t:outputLabel value="min"/>
</t:column>
<t:column>
<f:facet name="header">#{bundle['DESCRIPTION_HEADER']}</f:facet>
<t:inputText value="#{taskInfo.taskdescription}" />
<h:commandButton id="groupButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleGroupChange}">
<f:attribute name="groupid" value="#{row}" />
</h:commandButton>
<h:commandButton id="categoryButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleCategoryChange}">
<f:attribute name="categoryid" value="#{row}" />
</h:commandButton>
<h:commandButton id="activityButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleActivityChange}">
<f:attribute name="activityid" value="#{row}" />
</h:commandButton>
<h:commandButton id="subActivityButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleSubActivityChange}">
<f:attribute name="subactivityid" value="#{row}" />
</h:commandButton>
</t:column>
</t:dataTable>

The best solution for this is "t:selectOneRow" from tomahawk library
Java Side
private Long selectedRowIndex = -1L; //Along with it's getters and setters
JSP Side
<t:dataTable var="var" value="#{bean.beanList}"
style="border: 1px solid black;">
<t:column>
<t:selectOneRow value="#{bean.selectedRowIndex}" groupName="selection"
id="selectBtn">
</t:selectOneRow>
</t:column>
<t:column>
<f:facet name="header">
<h:outputLabel value="Names" />
</f:facet>
<t:outputText value="#{var.names}" />
</t:column>
<t:column>
<f:facet name="header">
<h:outputLabel value="Address" />
</f:facet>
<t:outputText value="#{var.address}" />
</t:column>
When the "selectedRowIndex" is -1L, that means nothing in the row is selected.
Whenever you need to set the page to no radio selected, then set this value to -1L.
The result should be something like this...

Related

preRenderView-Event triggered before an action

I am in a little bit of trouble with my preRenderView-Event. My page also uses a commandbutton to submit data but unfortunately the preRenderView-Event is always called before the buttons action is invoked.
<h:body style="width:600px; ">
<ui:composition template="/common/master-layout.xhtml">
<ui:define name="title">#{message['app.page.main.title']}</ui:define>
<ui:debug
rendered="#{initParam['javax.faces.PROJECT_STAGE'] eq 'Development'}"
hotkey="x" />
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{saisieDevisController.idDemande}" />
<f:event type="preRenderView"
listener="#{saisieDevisController.init}" />
</f:metadata>
</ui:define>
<ui:define name="content">
<p:fieldset legend="Programme" style="margin-top: 20px;">
<h:form id="etudeDemSaisieDevisForm">
<p:tabView id="etudeDemSaisieDevisTabView">
<p:tab id="programmeTab" title="Programme">
<h:panelGrid columns="4" cellpadding="10">
<h:outputText id="programmeInput" value="Programme"
style="font-weight:bold" />
<h:outputText for="programmeInput"
value="#{saisieDevisController.selectedDemande.idProgramme.codeProgImmobilier}" />
<h:outputText id="lotInput" value="Lot" style="font-weight:bold" />
<h:outputText for="lotInput"
value="#{saisieDevisController.selectedDemande.idBien.numLotCommercial}" />
<h:outputText id="nomAcqInput" value="Nom Acquereur"
style="font-weight:bold" />
<h:outputText for="nomAcqInput"
value="#{saisieDevisController.selectedDemande.idAcquereur.genreEtatCivil} #{saisieDevisController.selectedDemande.idAcquereur.prenomAcquereur} #{saisieDevisController.selectedDemande.idAcquereur.nomAcquereur}" />
</h:panelGrid>
</p:tab>
<p:tab id="datesFraisTab" title="Dates et frais">
<h:panelGrid columns="4" cellpadding="10">
<h:outputLabel value="Date de valité de devis"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.datValidite}"
id="dateValiditeDevis" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputLabel value="Date butoire de chantier"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.dateButoire}"
id="dateButoireDevis" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputText value="Frais de dossier" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraDossiers}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Aucun" itemValue="Aucun" />
<f:selectItem itemLabel="Déjà réglé" itemValue="Déjà réglé" />
<f:selectItem itemLabel="Charge Acquéreur"
itemValue="Charge Acquéreur" />
<f:selectItem itemLabel="Charge SNC" itemValue="Charge SNC" />
</p:selectOneMenu>
<h:outputLabel value="Date de plan de référence"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.datPlanReference}"
id="datePlanRef" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputText value="Frais de pilotage" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraPilotage}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Oui" itemValue="Oui" />
<f:selectItem itemLabel="Non" itemValue="Non" />
<f:selectItem itemLabel="Pour mémoire" itemValue="Pour mémoire" />
</p:selectOneMenu>
<h:outputText value="Frais de plan" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraPlan}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Aucun" itemValue="Aucun" />
<f:selectItem itemLabel="Charge Acquéreur"
itemValue="Charge Acquéreur" />
<f:selectItem itemLabel="Charge SNC" itemValue="Charge SNC" />
</p:selectOneMenu>
</h:panelGrid>
</p:tab>
<p:tab id="devisTab" title="Devis">
<h:panelGrid columns="2" cellpadding="10">
<h:panelGrid columns="4" cellpadding="10">
<h:outputText id="numDevis" value="Numéro de devis"
style="font-weight:bold" />
<h:inputText for="numDevis"
value="#{saisieDevisController.selectedDemande.lastDevis.numDevis}" />
<h:outputText id="dateRecepDemande"
value="Date de la réception de la demande"
style="font-weight:bold" />
<h:outputText for="dateRecepDemande"
value="#{saisieDevisController.selectedDemande.dateDemande}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText id="dateSaisieDevis"
value="Date de saisie de la demande" style="font-weight:bold" />
<h:outputText for="dateSaisieDevis"
value="#{saisieDevisController.selectedDemande.dateSaisie}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText id="ficheOptionDevis" value="Fiche d'oprion"
style="font-weight:bold" />
<h:outputText for="ficheOptionDevis"
value="#{saisieDevisController.selectedDemande.ficheOption}" />
</h:panelGrid>
</h:panelGrid>
</p:tab>
<p:tab id="previsualisationTab" title="Prévisualisation">
<h:panelGrid columns="2" cellpadding="10">
</h:panelGrid>
</p:tab>
</p:tabView>
<p:panel>
<ui:include src="ligneDataTable.xhtml" />
</p:panel>
<h:panelGrid columns="4" cellpadding="10"
style="text-align: center;margin-left: 25%;width: 50%; margin-right: 25%; margin-top: 30px; background-color:RGB(225,240,233)">
<h:outputText id="chargeSncHt" value="Charge SNC HT"
style="font-weight:bold" />
<h:outputText for="chargeSncHt"
value="#{saisieDevisController.selectedDemande.idDemande}" />
<h:outputText id="chargeAcqHt" value="Charge Acq HT"
style="font-weight:bold" />
<h:outputText for="chargeAcqHt" value="200" />
<h:outputText id="chargeSncTtc" value="Charge SNC TTC"
style="font-weight:bold" />
<h:outputText for="chargeSncTtc" value="0" />
<h:outputText id="chargeAcqTtc" value="Charge ACQ TTC"
style="font-weight:bold" />
<h:outputText for="chargeAcqTtc" value="0" />
</h:panelGrid>
<h:panelGrid columns="3" cellpadding="10" style="margin: 0 auto;">
<p:commandButton value="Valider" id="saveDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateValidate}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px">
</p:commandButton>
<p:commandButton value="Annuler" id="cancelDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateCancel}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px"
immediate="true" />
<p:commandButton value="Suspendre" id="suspendDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateSuspend}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px">
</p:commandButton>
</h:panelGrid>
</h:form>
</p:fieldset>
</ui:define>
</ui:composition>
Controller:
#Component
#Scope("view")
public class SaisieDevisController implements Serializable {
//...
#ManagedProperty("#{demandeController.selectedDemande}")
private DemandeDto selectedDemande;
private Long idDemande;
//...
public String init(){
if (!FacesContext.getCurrentInstance().isPostback()) {
selectedDemande = new DemandeDto();
selectedDemande.setIdBien(new BienDto());
listDescriptifs = new ArrayList<DescriptifDto>();
selectedDecriptif = new DescriptifDto();
actualize();
}
return null;
}
public String initLigne(){
ligneToSave = new LigneDto();
listLots = new ArrayList<LotDto>();
listLots = lotService.findAll();
listSituations = new ArrayList<SituationDto>();
listSituations = situationService.findAll();
listUnites = new ArrayList<UniteDto>();
listUnites = uniteService.findAll();
return "/views/demande/saisieDevis/addLigne?faces-redirect=true";
}
public void actualize(){
selectedDemande = saisieDevisService.findById(idDemande);
selectedDemande.setLastDevis(selectedDemande.getLastDevis());
}
With the JSF Lifecycle in mind, it is not really possible to have an preRenderView-Event being triggered before the "Invoke application" phase is finished. Please double-check the following:
Is the action invoked at all? In case of an converter/validation error the "invoke action" phase is skipped and the response is rendered instantly.
Are you calling the method from somewhere else? saisieDevisController.init sounds pretty generic. Maybe a trigger like #PostConstruct calls it earlier (nested).
Hope it helps...

<p:datatable> partial process does not reflect changes immediately

I have a code like:
<p:dataTable style="padding-top: 5px" var="leaveDetails" value="#{userLeaveBean.leaveDetails}" id="leaveDataTable" editable="true">
<p:column headerText="Leave Starts on" width="230">
<p:calendar valueChangeListener="#{userLeaveBean.handleFromDateChanege}" value="#{leaveDetails.dtLeaveFromDate}" pattern="dd-MMM-yyyy" size="16" showOn="button" id="editFrom">
<p:ajax event="dateSelect"/>
</p:calendar>
<h:selectOneRadio value="#{leaveDetails.strStartTiming}" valueChangeListener="#{userLeaveBean.handleRadioFirstValueChange}">
<f:selectItem itemValue="morning" itemLabel="Morning"/>
<f:selectItem itemValue="afternoon" itemLabel="Afternoon" />
<p:ajax event="click"/>
</h:selectOneRadio>
</p:column>
<p:column headerText="Leave Ends on" width="230">
<p:calendar valueChangeListener="#{userLeaveBean.handleToDateChanege}" value="#{leaveDetails.dtLeaveToDate}" pattern="dd-MMM-yyyy" size="16" showOn="button" id="editTo">
<p:ajax event="dateSelect"/>
</p:calendar>
<h:selectOneRadio value="#{leaveDetails.strEndTiming}" valueChangeListener="#{userLeaveBean.handleRadioSecondValueChange}">
<f:selectItem itemValue="noon" itemLabel="Noon"/>
<f:selectItem itemValue="endofday" itemLabel="End Of Day"/>
<p:ajax event="click"/>
</h:selectOneRadio>
</p:column>
<p:column headerText="Days" width="40" id="total">
<h:outputText value="#{leaveDetails.totalLeaveDays}"/>
</p:column>
<p:column headerText="Creation" width="100">
<h:outputText value="#{leaveDetails.dtApplicationDate}">
<f:convertDateTime pattern="EEEE,dd-MMM-yyyy"/>
</h:outputText>
</p:column>
<p:column headerText="Status" width="100">
<h:outputText value="#{leaveDetails.strLeaveStatus}"/>
</p:column>
<p:column headerText="Edit" width="40" rendered="#{leaveDetails.strLeaveStatus == 'Canceled' or leaveDetails.strLeaveStatus == 'Availed'}">
<p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" disabled="true" update="leaveDataTable" immediate="true" partialSubmit="true">
<h:graphicImage url="resources/images/edit.JPG"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
<f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
<f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
<f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Edit" width="40" rendered="#{leaveDetails.strLeaveStatus != 'Canceled'}">
<p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" disabled="false" update="leaveDataTable" immediate="true" process="#this" >
<h:graphicImage url="resources/images/edit.JPG"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
<f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
<f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
<f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Cancel" width="60" rendered="#{leaveDetails.strLeaveStatus == 'Canceled' or leaveDetails.strLeaveStatus == 'Availed'}">
<p:commandLink actionListener="#{userLeaveBean.cancelForLeave}" title="Cancel Request" disabled="true" process="#this" update="leaveDataTable" immediate="false">
<h:graphicImage url="resources/images/cancel.gif"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Cancel" width="60" rendered="#{leaveDetails.strLeaveStatus != 'Canceled'}">
<p:commandLink actionListener="#{userLeaveBean.cancelForLeave}" title="Cancel Request" disabled="false" process="#this" update="leaveDataTable" immediate="false" ajax="true">
<h:graphicImage url="resources/images/cancel.gif"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
</p:dataTable>
This part of code is written in a <p:datatable>.That means Row operation of a <p:datatable>.On clicking the <p:commandLink> some execution is happened, and I want it to reflect on the <p:datatable> immediatley. But it does not happen.
If I refresh the page, then the changes reflects for the row of the <p:datatable>. How can I modify my code to reflect the changes immediately.
Working on JSF2.0, primefaces 3.4.2, Jboss As7.1.1final and JDK6.0.
Bean is in #ViewScoped.
Please suggest.
Thanks in advance.

Problems with control of primefaces components by Managed Bean

I hope somebody could help me with the trouble I am having with JSF 2 and Primefaces 3.0M3.
the problem is that the back bean methods do not fired from any component in the layoutunit 'center' they are inside a form and nothing happens, even I tried to update the components with remoteCommand, autoUpdate of the outputpanel, commandButton with action and actionListener and nothing, there is no error message. In the layoutunit west works the components well, renders the outputpanel (pfpInfo) of the center layoutunit but I do not know what is happening.
here is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title>Articulos</title>
</h:head>
<h:body>
<link rel="stylesheet" type="text/css" href="../css/estilos.css" />
<p:layout fullPage="true" id="lay">
<p:layoutUnit position="north" size="100" resizable="false"
closable="false" collapsible="false">
<img src="../images/logo.jpg" alt="PLL"
style="width: 413px; height: 83px;" align="left"></img>ss
<img src="../images/tel.jpg" alt="PLR"
style="width: 413px; height: 83px;" align="right"></img>
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Categorías"
resizable="false" closable="false" collapsible="false">
<h:form id="frWest">
<p:growl id="message" showDetail="true" globalOnly="true"
autoUpdate="true"></p:growl>
<p:tree id="treeSingle" value="#{controlMBean.raizArbol}"
var="rama" dynamic="true" selectionMode="single"
selection="#{controlMBean.ramaElegida}" expanded="true">
<p:ajax event="select"
update=":frCenter:pfSeg :frCenter:pfpInfo :frCenter:pfpIma"
listener="#{controlMBean.procesaInformacionArt}"></p:ajax>
<p:treeNode>
<h:outputText value="#{rama}" styleClass="encabezadoUiLight" />
</p:treeNode>
</p:tree>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form id="frCenter">
<p:outputPanel id="pfSeg" rendered="true">
<p:outputPanel id="pfpIma" rendered="#{not controlMBean.cargado}">
<img src="../images/luchadores.jpg" />
</p:outputPanel>
<p:outputPanel id="pfpInfo" rendered="#{controlMBean.cargado}"
autoUpdate="true">
<p:dataTable dynamic="true" var="prnda" rowKey="#{prnda.id}"
value="#{controlMBean.infoArts}" paginator="true" rows="10"
selectionMode="single" paginatorAlwaysVisible="false"
selection="#{controlMBean.artElegido}"
rendered="#{controlMBean.cargado}">
<p:ajax event="rowUnselect"
listener="#{prestalana.deseleccionar}"></p:ajax>
<f:facet name="header">Articulo(s)</f:facet>
<p:ajax update=":frCenter:ppImg :frCenter:pgInfo"
oncomplete="prnd.show()" event="rowSelect"
listener="#{controlMBean.elegirFila}"></p:ajax>
<p:column sortBy="#{prnda.id}">
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{prnda.id}" />
</p:column>
<p:column sortBy="#{prnda.articulo}">
<f:facet name="header">
<h:outputText value="Modelo" />
</f:facet>
<h:outputText value="#{prnda.articulo}" />
</p:column>
<p:column sortBy="#{prnda.marca}">
<f:facet name="header">
<h:outputText value="Marca" />
</f:facet>
<h:outputText value="#{prnda.marca}" />
</p:column>
<p:column sortBy="#{prnda.edo}">
<f:facet name="header">
<h:outputText value="Ubicación" />
</f:facet>
<h:outputText value="#{prnda.edo}" />
</p:column>
<p:column sortBy="#{prnda.stsArticulo}">
<f:facet name="header">
<h:outputText value="Estatus" />
</f:facet>
<h:outputText value="#{prnda.stsArticulo} " />
</p:column>
<p:column sortBy="#{prnda.precio}">
<f:facet name="header">
<h:outputText value="Precio" />
</f:facet>
<h:outputText value="$ #{prnda.precio}" />
</p:column>
</p:dataTable>
<p:commandButton action="#{controlMBean.probar2}"
actionListener="#{controlMBean.probar}" value="Prueba"></p:commandButton>
</p:outputPanel>
<br />
<h:outputText value="#{controlMBean.mensaje}"
styleClass="textoUiLight" id="hotMen" />
</p:outputPanel>
<p:remoteCommand actionListener="#{controlMBean.probar}"
name="pruebaRc" update=":frCenter:ppImg"></p:remoteCommand>
<p:dialog appendToBody="true" dynamic="true" header="Info Prenda"
onShow="pruebaRc" widgetVar="prnd" resizable="false" width="750"
height="550" showEffect="fold" position="center"
hideEffect="explode">
<p:outputPanel id="ppImg" autoUpdate="true">
<h:panelGrid columns="2" id="pgInfo">
<p:galleria transitionInterval="3000" var="i"
value="#{controlMBean.imagenes}"
panelWidth="#{controlMBean.width}"
panelHeight="#{controlMBean.height}"
frameHeight="#{controlMBean.height/4}"
frameWidth="#{controlMBean.width/4}" effect="flash">
<p:graphicImage id="img" height="#{i.alto}" width="#{i.ancho}"
value="#{controlMBean.ruta}#{i.nombre}.jpg" />
</p:galleria>
<h:panelGrid columns="2" width="350">
<h:outputLabel value="ID:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.id}"
styleClass="resultado" />
<h:outputLabel value="Prenda:" styleClass="etiqueta" />
<h:outputText
value="#{controlMBean.artElegido.prenda} adasd"
styleClass="resultado" />
<h:outputLabel value="Precio:" styleClass="etiqueta" />
<h:outputText value="$#{controlMBean.artElegido.precio}"
styleClass="resultado" />
<h:outputLabel value="Marca:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.marca}"
styleClass="resultado" />
<h:outputLabel value="Sucursal:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.suc}"
styleClass="resultado" />
<h:outputLabel value="Descripcion:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.descr}"
styleClass="resultado" style="width:300px;height:100px;" />
</h:panelGrid>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body>
</html>

GET Parameter View Scoped Bean

I have a strange effect on my JSF2/richfaces 4 project. I use a viewscoped bean and a datascroller to view some data from my backing bean. The bean is viewscoped and to pass the figureId parameter I fire the preRenderView event.
<f:metadata>
<f:viewParam name="figureId" value="#{pointEdit.figureId}" >
<f:convertNumber pattern="###" />
</f:viewParam>
<f:event type="preRenderView" listener="#{pointEdit.init}" />
</f:metadata>
Displays fine, but when I click on the second site of the datascroller I get a nullponter exception for this line: <f:event type="preRenderView" listener="#{pointEdit.init}" />.
javax.el.ELException: /pointEdit.xhtml #17,66 listener="#{pointEdit.init}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2477)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2102)
at .....
Caused by: java.lang.NullPointerException
at com.ebcont.gtv.ePrometheus.web.backingbean.PointEdit.init(PointEdit.java:74) // <--first access to figure
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 27 more
My Bean:
#ManagedBean
#ViewScoped
public class PointEdit implements Serializable {
public void init() {
FigureService figureService = Utils.getSpringBean(FigureService.class);
figure = figureService .getById(figureId); // figureId will NOT be passed from GET
pointListToDisplay = figure.getPoints(); // nullpointer :-(
Before I imported my new data it worked fine on my test figures.
Why is my figureId GET Parameter not found in the init function? With my testdata (5 figures) I never had a problem with this.
UPDATE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<body>
<h:messages errorStyle="color:red" warnStyle="color:yellow" />
<rich:tabPanel switchType="client">
<rich:tab header="Punkte">
<rich:panel>
<f:facet name="header">
#{msg.pointEditDetail_figure_header }
</f:facet>
<div style="position: relative;">
<h:graphicImage url="/image?figureid=#{pointEdit.figure.id}"
style="border: solid 2px #013476;z-index: -2;">
<a4j:repeat value="#{pointEdit.points}" var="thepoi">
<h:panelGroup layout="block"
style="margin-top: -27px;top:#{thepoi.y}px; left: #{thepoi.x}px; background-image: url('images/poipin.png');background-repeat:none;width: 25px; height:27px; position:absolute; z-index: -0.9;display:none;"
styleClass="poi #{thepoi.id }">
<div style="margin-top: 27px;">
<a4j:repeat value="#{thepoi.labels}" var="poilabel">
<h:panelGroup layout="block"
styleClass="poilabel label#{thepoi.id}" style="display:none;">
<div style="color: white; z-index: 1; position: relative;">
<h:outputText value="#{poilabel.locale.isoCode}:"
style="background-image: url('images/layerbackground.png'); background-repeat: both;" />
<h:outputText value="#{poilabel.label.labelText}"
style="background-image: url('images/layerbackground.png'); background-repeat: both;"
rendered="#{not empty poilabel.label.labelText}" />
<h:outputText value="Nicht verfügbar"
style="background-image: url('images/layerbackground.png'); background-repeat: both;"
rendered="#{empty poilabel.label.labelText }" />
</div>
</h:panelGroup>
</a4j:repeat>
</div>
</h:panelGroup>
</a4j:repeat>
</h:graphicImage>
</div>
<br/>
<h:commandButton value="#{msg.pointEditDetail_show_all_button}"
onclick="$('.poi').toggle()"
rendered="#{ not empty pointEdit.points}" />
<h:button outcome="viewer.xhtml" value="#{msg.pointEditDetail_button_viewer}">
<f:param name="figureId" value="#{pointEdit.figure.id}"/>
<f:param name="zoom" value="1"/>
</h:button>
</rich:panel>
<br />
<rich:panel>
<f:facet name="header">
#{msg.pointEditDetail_points_header }
</f:facet>
<h:form>
<rich:dataTable value="#{pointEdit.points}" var="point"
id="pointtable" rows="10" rowKeyVar="rowId">
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_rowkey}
</f:facet>
#{rowId+1}
</rich:column>
<rich:column sortBy="#{point.id}" id="id"
sortOrder="#{pointEdit.pointIdOrder}">
<f:facet name="header">
<a4j:commandLink
value="#{msg.pointEditDetail_table_header_point} #{msg.pointEditDetail_table_header_id }"
render="pointtable" action="#{pointEdit.sortByPointId}" />
</f:facet>
#{point.id}
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_x}
</f:facet>
#{point.x }
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_y}
</f:facet>
#{point.y }
</rich:column>
<!-- filter (Object that extends Filter<?>), filterMethod, filterExpression -->
<rich:column filter="#{pointEdit.labelFilter}">
<f:facet name="header">
#{msg.pointEditDetail_table_header_label}
<h:inputText value="#{pointEdit.labelFilterText}">
<a4j:ajax event="change" render="pointtable" execute="#this" requestDelay="700"
ignoreDupResponses="true"/>
</h:inputText>
</f:facet>
<a4j:repeat var="pointlabel" value="#{point.labels}">
#{pointlabel.locale.isoCode}:
<h:outputText value="#{pointlabel.label.labelText}"
rendered="#{not empty pointlabel.label}" />
<h:outputText value="#{msg.pointEditDetail_not_available}"
rendered="#{empty pointlabel.label}" />
<br />
</a4j:repeat>
</rich:column>
<rich:column style="text-align:center">
<f:facet name="header">
#{msg.pointEditDetail_table_header_show_point}
</f:facet>
<h:selectBooleanCheckbox styleClass="pinchk#{point.id}"
value="false"
onchange="checkboxdrivendisplay(this,'.#{point.id }');checkboxdrivendisplay(this,'.lblchk#{point.id }');"
onmouseover="jQuery('.#{point.id }').show(); jQuery('.lblchk#{point.id }').show();"
onmouseout="checkboxdrivendisplay(this,'.#{point.id }');checkboxdrivendisplay(this,'.lblchk#{point.id }');">
</h:selectBooleanCheckbox>
</rich:column>
<rich:column style="text-align:center;">
<f:facet name="header">
#{msg.pointEditDetail_table_header_show_label}
</f:facet>
<h:selectBooleanCheckbox style="display:none"
styleClass="lblchk#{point.id}" value="false"
onclick="checkboxdrivendisplay(this,'.label#{point.id }');"
onmouseover="jQuery('.label#{point.id}').show();"
onmouseout="checkboxdrivendisplay(this,'.label#{point.id }');">
</h:selectBooleanCheckbox>
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_edit_label }
</f:facet>
<center>
<h:link outcome="labelEdit.xhtml" value="#{msg.pointEditDetail_table_edit_label}">
<f:param name="pointId" value="#{point.id}"/>
</h:link>
</center>
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_tag }
</f:facet>
<a4j:repeat var="tag" value="#{point.tags}" varStatus="index">
<h:link outcome="search.xhtml" value="#{tag.tag}">
<f:param name="tags" value="true" />
<f:param name="labels" value="false" />
<f:param name="legends" value="false" />
<f:param name="query" value="#{tag.tag}" />
</h:link>
</a4j:repeat>
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_table_header_edit_tag }
</f:facet>
<center>
<h:link outcome="tagEdit.xhtml" value="#{msg.pointEditDetail_table_edit_tag}">
<f:param name="pointId" value="#{point.id}"/>
</h:link>
</center>
</rich:column>
<f:facet name="footer">
<rich:dataScroller for="pointtable" />
</f:facet>
</rich:dataTable>
</h:form>
</rich:panel>
</rich:tab>
<rich:tab header="Daten">
<h:form>
<rich:panel id="legendpanel">
<f:facet name="header">
#{msg.pointEditDetail_legend_edit_header }
</f:facet>
<h:outputText rendered="#{not empty pointEdit.legendeStatus}"
value="#{msg.pointEditDetail_legend_edit_success}" />
<br />
<h:inputTextarea value="#{pointEdit.legende}" cols="40" rows="8"/> <br /> <br />
<a4j:commandButton value="#{msg.pointEditDetail_legend_edit_button} "
render="legendpanel legende" action="#{pointEdit.editLegend}" />
</rich:panel>
</h:form>
<br />
<h:form>
<rich:panel name="labelPanel">
<f:facet name="header">
#{msg.pointEditDetail_label_edit_header }
</f:facet>
<rich:dataTable value="#{pointEdit.labels}" var="label"
id="labelTable" rows="10">
<rich:column>
<f:facet name="header">
Id
</f:facet>
#{label.id }
</rich:column>
<rich:column>
<f:facet name="header">
#{msg.pointEditDetail_label_edit_table_header}
</f:facet>
<rich:inplaceInput value="#{label.labelText }" showControls="true" layout="block" style="width: 98%"
required="true">
<a4j:ajax event="change" render="pointtable" listener="#{pointEdit.editLabel(label.id) }" />
</rich:inplaceInput>
</rich:column>
<f:facet name="footer">
<rich:dataScroller for="labelTable" />
</f:facet>
</rich:dataTable>
</rich:panel>
</h:form>
<br />
</rich:tab>
<rich:tab header="Verknüpfen">
<ui:include src="linkFigures.xhtml" />
</rich:tab>
</rich:tabPanel>
<script type="text/javascript" src="javascript/eprometheus.js"></script>
</body>
</html>
You need to either pass that parameter as <f:param> in the command link so that it retains in the subsequent request:
<h:commandLink>
<f:param name="figureId" value="#{pointEdit.figureId}" />
</h:commandLink>
or to check in the init() if FacesContext#isPostback() equals to false before proceeding (so that it only runs on a fresh new GET request, not in the subsequent postbacks as the bean is view scoped and the properties are already been set anyway):
public void init() {
if (!FacesContext.getCurrentInstance().isPostback()) {
// ...
}
}
My new test images where 5 times larger then the images i got 4 testing. In my ViewScoped bean i had the figure as property so the whole byte[] had to be serialized.
After removing this design flaw it works again and also explains why the new images cause troubles!

Dropdown's valueChangeListener not working with primefaces datatable

I have datatable and a dropdown within a xhtml. If I am deleting p:datatable code within this page then I am able to call the valueChangeListener of dropdown , but if p:datatable is present in xhtml, then I am not able to call it.
Xhtml code is
<ui:define name="content">
<f:view>
<h:form id="accountSummaryForm" prependId="false">
<h:selectBooleanCheckbox id="checkbox" value="true" />
<h:outputLabel value="Show certificates preview on sumit"></h:outputLabel>
<h:outputLabel value="Show certificates preview on sumit"></h:outputLabel>
<h:outputText align="left"
value="Value is #{reqSummaryHandler.certNumber}" />
<p:dataTable id="reqActList" paginatorAlwaysVisible="true"
var="reqInfo" value="#{reqSummaryHandler.certActListModel}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginator="true" rows="#{label.accountList_defaultNumberOfRows}"
selectionMode="single"
rowsPerPageTemplate="#{label.accountList_numberOfRows}" width="60%">
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="#{label.certNumber}" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.certNumber}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Version" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.certVersionNbrString}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Insured" />
</f:facet>
<ui:repeat value="#{reqInfo.clientList}" var="insuredInfo">
<h:outputText align="left"
value="#{insuredInfo.generalPartyInfo.nameInfo.commName.commercialName}" />
</ui:repeat>
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Certificate Holder" />
</f:facet>
<ui:repeat value="#{reqInfo.certificateHolderInfoList}"
var="certHoldInfo">
<h:outputText align="left"
value="#{certHoldInfo.additionalInterest.generalPartyInfo.nameInfo.commName.commercialName}" />
</ui:repeat>
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Activity Performed" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.effectiveTypeCd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Certificate Status" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.statusCd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Third Party" />
</f:facet>
<h:outputText align="left"
value="#{reqInfo.certWordingEndorsementInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Manual Form" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.manualEntryInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Manual Addendum" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.mnlAddendumInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Path" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText align="left" value="#{reqInfo.routePathCd}"
readonly="true" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{reqInfo.routePathCd}">
<f:selectItem itemLabel="Issue Distribute" itemValue="A" />
<f:selectItem itemLabel="Send to Underwriter" itemValue="B" />
<f:selectItem itemLabel="Issue Do Not Distribute"
itemValue="C" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
<p:rowEditor rendered="#{reqInfo.statusCd eq 'A'}" />
</p:column>
<p:column style="text-align:center;white-space: normal;nowrap">
<f:facet name="header">
<h:outputLabel value="Action" />
</f:facet>
<ui:repeat value="#{reqInfo.availableFunctions.functionNameArray}"
var="linkInfo">
<p:commandLink id="View" value="#{linkInfo}" ajax="false" />
<br />
</ui:repeat>
</p:column>
</p:dataTable>
<p:spacer width="50" height="0"></p:spacer>
<p:spacer width="50" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<h:outputLabel value="Assign Path" style="font-weight:bold" />
<p:spacer width="5" height="10" />
<h:selectOneMenu id="dropdown2"
valueChangeListener="#{reqSummaryHandler.DoPathProcessing1}"
value="#{reqSummaryHandler.certNumber}" onchange="submit();">
<f:selectItem itemLabel="Issue Distribute" itemValue="A" />
<f:selectItem itemLabel="Send to Underwriter" itemValue="B" />
<f:selectItem itemLabel="Issue Do Not Distribute" itemValue="C" />
</h:selectOneMenu>
</h:form>
</f:view>
</ui:define>
And listener code is
public void DoPathProcessing1(ValueChangeEvent event) {
String newValue = (String) event.getNewValue();
System.out.println("Path"
+ certActListModel.getRowData().getRoutePathCd());
certActListModel.getRowData().setRoutePathCd(newValue);
System.out.println("value is " + newValue);
}
Any idea why it is not working?
I am using jsf-api-2.0.3 and primefaces-2.2.1
You are using both the value and the valueChangeListener attributes of the drop down component. Why would you do this?
Just having value="#{reqSummaryHandler.certNumber} will call setCertNumber(String certNumber) in your managed bean. Why not just put this code into the setter method?

Resources