There are several primefaces inputtext controls and commandbuttons in a single form. Pressing the return ket on one inputtext need to activate the click of related commandbutton. How can I achieve that functionality? I tried to use onkeydown even, but could not find out the method.
You can try(you need to find to detect enter key in javascript by yourself)
xhtml:
<p:input onkeydown="test()" />
<p:commandButton styleClass="foo" />
javascript:
function test(){
$('.foo').click();
}
You can see also:
How-to-programmatically-trigger-onclick-event
and
How-to-refer-to-a-jsf-component-id-in-jquery
As guided by RongNK, I changed my code as below and it serves my purpose perfectly.
Added CDATA to include JavaScript.
Used \\ to escape : in id of JSF compoents
<h:form id="frmEn">
<script type="text/javascript" language="JavaScript">
//<![CDATA[
function forDx(e) {
if (e.keyCode === 13) {
$('#frmEn\\:btnDx').click();
return false;
} else {
return true;
}
}
function forIx(e) {
if (e.keyCode === 13) {
$('#frmEn\\:btnIx').click();
return false;
} else {
return true;
}
}
function forMx(e) {
if (e.keyCode === 13) {
$('#frmEn\\:btnMx').click();
return false;
} else {
return true;
}
}
function forRx(e) {
if (e.keyCode === 13) {
$('#frmEn\\:btnRx').click();
return false;
} else {
return true;
}
}
// ]]>
</script>
<p:panel header="Encounter" >
<h:panelGrid columns="2" >
<p:panel header="Encounter Details" >
<h:panelGrid columns="4" >
<h:outputLabel value="Tests" ></h:outputLabel>
<p:autoComplete id="txtIx" value="#{encounterController.test }" completeMethod="#{encounterController.completeIx}" styleClass="defaultTxt" onkeydown="return forIx(event)" >
</p:autoComplete>
<h:commandButton id="btnIx" value="Add" action="#{encounterController.addTest()}">
<f:ajax execute="btnIx txtIx" render="tblIx" />
</h:commandButton>
<p:dataTable value="#{encounterController.ecIxs }" var="ix" id="tblIx" >
<p:column >
<f:facet name="header" >
<h:outputLabel value="Tests"/>
</f:facet>
<h:outputLabel value="#{ix.concept.name}"></h:outputLabel>
</p:column>
</p:dataTable>
<h:outputLabel value="Diagnosis" ></h:outputLabel>
<p:autoComplete id="txtDx" value="#{encounterController.diagnosis }" completeMethod="#{encounterController.completeDx}" styleClass="defaultTxt" onkeydown="return forDx(event)" />
<h:commandButton id="btnDx" value="Add" action="#{encounterController.addDiagnosis()}" >
<f:ajax execute="btnDx txtDx" render="tblDx txtDx" />
</h:commandButton>
<p:dataTable value="#{encounterController.ecDxs }" var="dx" id="tblDx" >
<p:column >
<f:facet name="header" >
<h:outputLabel value="Diagnoses"/>
</f:facet>
<h:outputLabel value="#{dx.concept.name}"></h:outputLabel>
</p:column>
</p:dataTable>
<h:outputLabel value="Treatment" ></h:outputLabel>
<p:autoComplete id="txtRx" value="#{encounterController.rx}" completeMethod="#{encounterController.completeRx}" styleClass="defaultTxt" onkeydown="return forRx(event)">
</p:autoComplete>
<h:commandButton id="btnRx" value="Add" action="#{encounterController.addRx()}">
<f:ajax execute="btnRx txtRx" render="tblRx" />
</h:commandButton>
<p:dataTable value="#{encounterController.ecRxs }" var="rx" id="tblRx" >
<p:column >
<f:facet name="header" >
<h:outputLabel value="Treatment"/>
</f:facet>
<h:outputLabel value="#{rx.concept.name}"></h:outputLabel>
</p:column>
</p:dataTable>
<h:outputLabel value="Plan" ></h:outputLabel>
<p:autoComplete id="txtMx" value="#{encounterController.plan }" completeMethod="#{encounterController.completeMx}" styleClass="defaultTxt" onkeydown="return forMx(event)">
</p:autoComplete>
<h:commandButton id="btnMx" value="Add" action="#{encounterController.addPlanOfAction() }">
<f:ajax execute="btnMx txtMx" render="tblMx" />
</h:commandButton>
<p:dataTable value="#{encounterController.ecMxs}" var="mx" id="tblMx" >
<p:column >
<f:facet name="header" >
<h:outputLabel value="Plan"/>
</f:facet>
<h:outputLabel value="#{mx.concept.name}"></h:outputLabel>
</p:column>
</p:dataTable>
<h:outputLabel value="Details" ></h:outputLabel>
<h:inputTextarea value="#{encounterController.current.comments}" styleClass="defaultTxtArea"></h:inputTextarea>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="Charges" ></h:outputLabel>
<h:inputTextarea value="#{encounterController.current.charge}" styleClass="defaultTxt"></h:inputTextarea>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value=""></h:outputLabel>
<h:commandButton value="Save" action="#{encounterController.saveSelected()}"></h:commandButton>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
</h:panelGrid>
</p:panel>
<p:panel header="Patient Details" >
<h:panelGrid columns="2" >
<h:outputLabel value="Name"></h:outputLabel>
<h:outputLabel value="#{encounterController.current.patient.person.name}"></h:outputLabel>
<h:outputLabel value="Age"></h:outputLabel>
<h:outputLabel value="#{encounterController.current.patient.person.age}"></h:outputLabel>
<h:outputLabel value="Date of Birth"></h:outputLabel>
<h:outputLabel value="#{encounterController.current.patient.person.dob}">
<f:convertDateTime pattern="dd MMMM yyyy" />
</h:outputLabel>
<h:outputLabel value="Sex"></h:outputLabel>
<h:outputLabel value="#{encounterController.current.patient.person.sex.name}"></h:outputLabel>
<h:outputLabel value="Address"></h:outputLabel>
<h:outputLabel value="#{encounterController.current.patient.person.address}"></h:outputLabel>
</h:panelGrid>
</p:panel>
</h:panelGrid>
</p:panel>
</h:form>
Related
Hi I wanna ask something, I try to make a form for website using java with primeface, I make this form with 2 page but when I try to input data, the data from second page can't set on database sometimes when I try to modify the code the data on first page can't set but the data on second page can be set on database
this my code for save data
public String save(){
String nextPage = "";
PRPKUserNonIt PRPKUser = new PRPKUserNonIt();
PRPKUser prpkUser = new PRPKUser();
setListUserSelected(chooseBean.getListSelecteduser());
try{
prpkUserController.save(prpkUser);
nextPage = "/prpk/master_prpk.xhtml?faces-redirect=true";
RequestContext rq = RequestContext.getCurrentInstance();
rq.execute("PF('successDialog').show();");
}catch(Exception e){
e.printStackTrace();
FacesMessage messageFailed = new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error","Save data failed");
RequestContext.getCurrentInstance().showMessageInDialog(messageFailed);
nextPage = "#";
}
Group group = new Group();
setListGroupSelected(chooseTargetSDDialogBean.getGroupSelection());
try{
groupController.save(group);
nextPage = "/prpk/master_prpk.xhtml?faces-redirect=true";
RequestContext rq = RequestContext.getCurrentInstance();
rq.execute("PF('successDialog').show();");
}catch(Exception e){
e.printStackTrace();
FacesMessage messageFailed = new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error","Save data failed");
RequestContext.getCurrentInstance().showMessageInDialog(messageFailed);
nextPage = "#";
}
PRPKNon PRPKNon = new PRPKNon();
PRPKNon.setUser_non_itId(userLogin.getId());
PRPKNon.setSenderId(userLogin.getId());
PRPKNon.setPic_prpkId(userLogin.getId());
PRPKNon.setCreatedBy(userLogin.getName());
PRPKNon.setUpdatedBy(userLogin.getName());
for (Map.Entry<String, Integer> e : prpkTypeIdMap.entrySet()) {
if (prpkTypeTypeId.equals(e.getValue())) {
prpkTypeType = e.getKey();
continue;
}
}
PRPKNon.setPrpkTypeId(prpkTypeTypeId); //diubah
PRPKNon.setPrpkTypeName(prpkTypeType);
PRPKNon.setPrpkDesc(prpkDesc);
PRPKNon.setMemoNumber(memoNumber);
for (Map.Entry<String, Integer> e : priorityIdMap.entrySet()) {
if (priorityTypeId.equals(e.getValue())) {
priorityType = e.getKey();
continue;
}
}
setPriorityLevelId(priorityTypeId);
setPriorityName(priorityType);
for (Map.Entry<String, Integer> e : departmentIdMap.entrySet()) {
if (departmentTypeId.equals(e.getValue())) {
departmentType = e.getKey();
continue;
}
}
for (Map.Entry<String, Integer> e : businessUnitIdMap.entrySet()) {
if (businessUnitTypeId.equals(e.getValue())) {
businessUnitType = e.getKey();
continue;
}
}
PRPKNon.setPriorityId(getPriorityLevelId());//diubah
PRPKNon.setPriorityLevel(getPriorityName());
PRPKNon.setBusinessUnitId(getBusinessId());
PRPKNon.setBusinessUnitName(getBussinessName());
PRPKNon.setPicDepartmentId(getDepartmentId());
PRPKNon.setDepartmentName(getDepartmentNames());
PRPKNon.setBusinessUnitId(getBusinessUnitId());
PRPKNon.setPicDepartmentId(departmentTypeId);//diubah
System.out.println("Pic : "+ prpk.getPicDepartmentId());
PRPKNon.setDepartmentName(departmentType);
PRPKNon.setBusinessUnitId(businessUnitTypeId);//diubah
PRPKNon.setBusinessUnitName(businessUnitType);
nextPage = "/prpk/next_prpk_new.xhtml?faces-redirect=true";
PRPKNon.setPrpkRequest(prpkRequest);
PRPKNon.setPrpkBackground(prpkBackground);
PRPKNon.setPrpk_analysisBenefit(prpk_analysisBenefit);
try{
prpkNonController.save(PRPKNon);
nextPage = "/prpk/next_prpk_new.xhtml?faces-redirect=true";
RequestContext rq = RequestContext.getCurrentInstance();
rq.execute("PF('successDialog').show();");
}catch(Exception e){
e.printStackTrace();
FacesMessage messageFailed = new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error","Save data failed");
RequestContext.getCurrentInstance().showMessageInDialog(messageFailed);
nextPage = "#";
}
return nextPage;
}
this xhtml for the first page
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
template="/user_templates/template.xhtml">
<ui:define name="metadata">
</ui:define>
<ui:define name="content">
<h:form id="formId" style="margin-top:35;" prependId="false">
<p:contextMenu>
<p:menuitem value="© Indomaret" />
</p:contextMenu>
<p:breadCrumb>
<p:menuitem value="Home" />
<p:menuitem value="PRPK" />
<p:menuitem value="List PRPK"/>
<p:menuitem value="Add New PRPK"/>
<p:menuitem value="#{pRPKUserNonItBean.header}" />
</p:breadCrumb>
<h:panelGrid id="TableInputId" columns="2" cellpadding="10" >
<h:panelGrid id="inputGridId1" columns="3" cellpadding="10" >
<p:outputLabel value="PRPK Type" for="prpktypeTxt" />
<p:selectOneMenu id="prpktypeTxt" value="#{pRPKUserNonItBean.prpkTypeTypeId}"
>
<p:ajax listener="#{pRPKUserNonItBean.updateButton}" update="formId"/>
<f:selectItem itemLabel="None Selected" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{pRPKUserNonItBean.prpkTypeIdMap}" />
</p:selectOneMenu>
<p:message for="prpktypeTxt" display="icon" />
<p:outputLabel value="PRPK Reference" for="prpkReferenceTxt" />
<h:panelGrid columns="2" cellpadding="0" border="0">
<p:inputText id="prpkReferenceTxt" disabled="true"
readonly="true" style="width:200; height:25"
value="#{pRPKUserNonItBean.prpkReference}" />
<p:commandButton icon="ui-icon-search"
action="#{pRPKUserNonItBean.showPRPKReferenceDialog}" rendered="#{pRPKUserNonItBean.prpkReferenceRendered}" process="#this">
<p:ajax event="dialogReturn" update="prpkReferenceTxt" />
</p:commandButton>
</h:panelGrid>
<p:message for="prpkReferenceTxt" display="icon"></p:message>
<p:outputLabel value="Description" for="descriptionTxt" />
<p:inputTextarea id="descriptionTxt" required="true" style="width:300; height:50"
value="#{pRPKUserNonItBean.prpkDesc}" />
<p:message for="descriptionTxt" display="icon"></p:message>
<p:outputLabel value="Memo" for="memoTxt"
style="display:block; width:100px;" />
<p:inputText id="memoTxt" required="true" style="width:225; height:25"
value="#{pRPKUserNonItBean.memoNumber}" />
<p:message for="memoTxt" display="icon"></p:message>
</h:panelGrid>
<h:panelGrid id="inputGridId2" columns="3" cellpadding="10" >
<p:outputLabel value="Priority Level" for="prioritylevelTxt" />
<p:selectOneMenu id="prioritylevelTxt" value="#{pRPKUserNonItBean.priorityTypeId}"
>
<f:selectItem itemLabel="None Selected" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{pRPKUserNonItBean.priorityIdMap}" />
</p:selectOneMenu>
<p:message for="prioritylevelTxt" display="icon" />
<p:outputLabel value="Department" for="departmentTxt" />
<p:selectOneMenu id="departmentTxt" value="#{pRPKUserNonItBean.departmentTypeId}"
>
<f:selectItem itemLabel="None Selected" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{pRPKUserNonItBean.departmentIdMap}" />
</p:selectOneMenu>
<p:message for="departmentTxt" display="icon" />
<p:outputLabel value="OPU" for="opuTxt" />
<p:selectOneMenu id="opuTxt" value="#{pRPKUserNonItBean.businessUnitTypeId}"
>
<f:selectItem itemLabel="None Selected" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{pRPKUserNonItBean.businessUnitIdMap}" />
</p:selectOneMenu>
<p:message for="opuTxt" display="icon" />
<p:row></p:row><p:row></p:row><p:row></p:row>
<p:row></p:row><p:row></p:row><p:row></p:row>
<p:row></p:row><p:row></p:row><p:row></p:row>
<p:row></p:row><p:row></p:row><p:row></p:row>
<p:row></p:row><p:row></p:row><p:row></p:row>
</h:panelGrid>
</h:panelGrid>
<p:outputLabel value="Target SD *" style="border:0;margin-top:10;margin-left:25;"/>
<h:panelGrid width="60%">
<p:commandButton value="Select Target SD"
action="#{pRPKUserNonItBean.showTargetSDDialog()}" immediate="true" >
<p:ajax event="dialogReturn" update="targetTable"/>
</p:commandButton>
<p:dataTable
paginatorPosition="bottom" rows="3" paginator="true"
rowsPerPageTemplate="10,15,25,50,100" rowIndexVar="rowIndex"
currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
style="font-size:12px;"
var="group" widgetVar="targetTables" value="#{chooseTargetSDDialogBean.listGroupTemp}" id="targetTable">
<p:column headerText="No" width="5%">
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Target SD" width="40%">
<h:outputText value="#{group.name}" />
</p:column>
<p:column headerText="Description" width="45%">
<h:outputText value="#{group.description}" />
</p:column>
<p:column headerText="Delete" width="10%">
<center>
<p:commandButton icon="ui-icon-trash" action="#{chooseTargetSDDialogBean.deleteChooseGroupTargetSD(group)}" update="targetTable" immediate="true"/>
</center>
</p:column>
</p:dataTable>
</h:panelGrid>
<p:commandButton value="Cancel"
style="position: relative; bottom: -15px;" icon="ui-icon-circle-close"
process="#this" action="/prpk/master_prpk.xhtml?faces-redirect=true" />
<p:commandButton value="Next"
style="float:right; position: relative; bottom: -15px;" icon="ui-icon-arrow-1-e"
action="#{PRPKUserNonItBean.save}" process="#this">
<!-- <p:confirm header="Confirmation"
message="Are you sure the data correct ?" icon="ui-icon-alert" /> -->
</p:commandButton>
</h:form>
</ui:define>
and this xhtml for the second page
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
template="/user_templates/template.xhtml">
<ui:define name="metadata">
</ui:define>
<ui:define name="content">
<h:form id="formId" style="margin-top:35;">
<p:contextMenu>
<p:menuitem value="© Indomaret" />
</p:contextMenu>
<p:breadCrumb>
<p:menuitem value="PRPK" />
<p:menuitem value="PRPK" />
<p:menuitem value="List PRPK" />
<p:menuitem value="Add New PRPK"
url="/prpk/prpk_new.xhtml?faces-redirect=true" />
<p:menuitem value="#{pRPKUserNonItBean.header}" />
</p:breadCrumb>
<h:panelGrid style="margin-left:5;margin-top:20;">
<h2>PIC PRPK *</h2>
</h:panelGrid>
<h:panelGrid style="margin-left:0;margin-bottom:20;margin-top:5;">
<p:commandButton value="Select PIC PRPK" icon="ui-icon-circle-plus"
action="#{pRPKUserNonItBean.showPicPRPKDialog}" immediate="true">
<p:ajax event="dialogReturn" update="roleTbl" />
</p:commandButton>
<p:dataTable var="prpk" id="roleTbl"
value="#{chooseNonITUserDialogBean.listUserTemp}">
<p:column headerText="Name">
<h:outputText value="#{prpk.name}" />
</p:column>
<p:column headerText="Department">
<h:outputText value="#{prpk.departmentName}" />
</p:column>
<p:column headerText="Head user">
<h:outputText value="#{prpk.headUserName}" />
</p:column>
<p:column headerText="Delete" width="10%">
<center>
<p:commandButton icon="ui-icon-trash"
action="#{chooseNonITUserDialogBean.deleteUser(prpk)}"
update="roleTbl"
immediate="true" />
</center>
</p:column>
</p:dataTable>
</h:panelGrid>
<h:panelGrid columns="3" cellpadding="5" style="margin-left:10;">
<p:outputLabel value="Request" for="requestTxt"
style="display:block; width:100px;" />
<p:inputTextarea id="requestTxt" required="true"
style="width:700; height:25" value="#{pRPKUserNonItBean.prpkRequest}" />
<p:message for="requestTxt" display="icon"></p:message>
<p:outputLabel value="Background" for="backgroundTxt" />
<p:inputTextarea id="backgroundTxt" style="width:700; height:25"
value="#{pRPKUserNonItBean.prpkBackground}" />
<p:message for="backgroundTxt" display="icon"></p:message>
<p:outputLabel value="Benefit Analysis" for="beNalTxt" />
<p:inputTextarea id="beNalTxt" style="width:700; height:25"
value="#{pRPKUserNonItBean.prpk_analysisBenefit}" />
<p:message for="beNalTxt" display="icon"></p:message>
</h:panelGrid>
<h:panelGrid columns="2" style="margin-left:120;">
<p:commandButton value="Back"
style="height:25; font-weight:bold; margin-left:5;"
icon="ui-icon-circle-close" process="#this"
action="/prpk/prpk_new.xhtml?faces-redirect=true" />
<p:commandButton id="submitBtn" value="#{pRPKUserNonItBean.buttonName}"
style=" font-weight:bold;margin-left:10;"
type="submit" icon="ui-icon-disk" action="#{pRPKUserNonItBean.saveEdit}"
update="formId" />
<p:defaultCommand target="submitBtn" />
</h:panelGrid>
<p:dialog modal="false" widgetVar="successDialog" header="Info"
closable="false">
<h:panelGrid columns="1" cellpadding="2">
<h:outputText value="Save data berhasil" />
<center>
<p:commandButton value="Ok"
action="/prpk/master_prpk.xhtml?faces-redirect=true"
onclick="PF('successDialog').hide()" />
</center>
</h:panelGrid>
</p:dialog>
<p:dialog modal="false" widgetVar="failedDialog" header="Info"
closable="false">
<h:panelGrid columns="1" cellpadding="2">
<h:outputText value="Save data failed" />
<center>
<p:commandButton value="Ok" action="#"
onclick="PF('failedDialog').hide()" />
</center>
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
I´m trying to show the progress of several batch processes using a progressbar for each one of them. The problem is that only one progressbar is been sent to server side (the last one). Here is the code...
I made a RequestScoped Named bean for the progress beacause I read that for multiple progressBar it is needed a bean instance for each one of the progressbars, but that do not resolve my problem.
I'm using Primefaces 6.1 with JSF 2.2.
Any ideas? Thanks!
<h:form id="formExecutions">
<p:dataGrid id="jobs" value="#{jobExecutorController.jobExecutions}" var="job" rows="5" paginator="true" emptyMessage="#{MessageResources['text.noRecordsFound']}"
paginatorPosition="bottom" columns="1" layout="grid">
<f:facet name="header">
#{MessageResources['text.batchProcesses']}
</f:facet>
<p:outputPanel layout="block" >
<p:panelGrid cellpadding="5" styleClass="vf-panelGrid">
<p:row style="width:100%">
<p:column>
<p:outputLabel for="executionId" value="#{MessageResources['text.executionId']}:" style="font-weight:bold"/>
</p:column>
<p:column>
<h:outputText id="executionId" value="#{job.executionId}" />
</p:column>
<p:column>
<p:outputLabel for="name" value="#{MessageResources['text.name']}:" style="font-weight:bold"/>
</p:column>
<p:column style="width:10%">
<h:outputText id="name" value="#{job.name}"/>
</p:column>
<p:column style="width:50%" rowspan="2">
<p:progressBar id="progressBar" widgetVar="progressBar" ajax="true" value="#{progressController.progress(job)}" labelTemplate="{value}%" styleClass="animated" style="height: 20px; line-height: 20px;" global="false" interval="3000">
<p:ajax event="complete" listener="#{progressController.onCompleteJob(job)}" update="messageDisplay" process="#this"/>
<p:ajax update="jobInfo"/>
</p:progressBar>
</p:column>
<p:column style="width:4%" />
<p:column rowspan="2" style="text-align:right">
<p:commandButton id="restart" onclick="PF('confirmRestartJob').show()" styleClass="coloured-icons-batch restart-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="restart" value="#{MessageResources['text.restartJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="stop" onclick="PF('confirmStopJob').show()" styleClass="coloured-icons-batch stop-image-icon blink"
disabled="#{not job.enableStop}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="stop" value="#{MessageResources['text.stopJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="abandon" onclick="PF('confirmAbandonJob').show()" styleClass="coloured-icons-batch abandon-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="abandon" value="#{MessageResources['text.abandonJobExecution']}" position="top"></p:tooltip>
</p:column>
</p:row>
</p:panelGrid>
<h:panelGroup id="jobInfo" >
<p:panelGrid columns="4" cellpadding="5" styleClass="vf-panelGrid">
<p:outputLabel for="creationDate" value="#{MessageResources['text.creationDate']}:" style="font-weight:bold"/>
<h:outputText id="creationDate" value="#{job.formattedDate(job.createdDate)}" />
<p:outputLabel for="startDate" value="#{MessageResources['text.dateStartProcess']}:" style="font-weight:bold"/>
<h:outputText id="startDate" value="#{job.formattedDate(job.startedDate)}" />
<p:outputLabel for="lastUpdate" value="#{MessageResources['text.lastUpdate']}:" style="font-weight:bold"/>
<h:outputText id="lastUpdate" value="#{job.formattedDate(job.lastUpdate)}" />
<p:outputLabel for="toProcess" value="#{MessageResources['text.itemsToProcess']}:" style="font-weight:bold"/>
<h:outputText id="toProcess" value="#{job.itemsToProcess}" />
<p:outputLabel for="endDate" value="#{MessageResources['text.ended']}:" style="font-weight:bold"/>
<h:outputText id="endDate" value="#{job.formattedDate(job.endedDate)}" />
<p:outputLabel for="processed" value="#{MessageResources['text.itemsProcessed']}:" style="font-weight:bold"/>
<h:outputText id="processed" value="#{job.itemsProcessed}" />
<p:outputLabel for="status" value="#{MessageResources['text.state']}:" style="font-weight:bold"/>
<h:outputText id="status" value="#{job.status}" />
</p:panelGrid>
</h:panelGroup>
</p:outputPanel>
<p:spacer width="5"/>
<p:separator />
<p:spacer width="5"/>
</p:dataGrid>
My RequestScope backing bean...
#Named("progressController")
#RequestScoped
public class ProgressController
{
#EJB
private EJBJobRepositoryLocal ejbJobRepository;
public Long progress(DMJob jobExecution) throws VfCmsSqlException
{
if (jobExecution.getStatus().equals(BatchStatus.STARTED.name())) {
jobExecution.setProgress(ejbJobRepository.getJobProgress(jobExecution.getExecutionId()));
}
PrimeUtil.get().update("formExecutions:jobInfo");
return jobExecution.getProgress();
}
public void onCompleteJob(DMJob jobExecution)
{
Object[] parameters = {jobExecution.getName(), jobExecution.getExecutionId()};
Messages.displayInfoMessage("text.jobComplete", parameters);
}
}
Ok. The problem is that the PrimeFaces().start() method is not been executed over all the components generated by JSF. So, what I did is a javascript function which is executed when the page is fully loaded. In my case the components that I needed to initialize are several progress bar. My components are inside a data scroller which is inside a form, that's why I concat those id's. The 'i' is the index of each of the rendered progress bar in the page.
<script type="text/javascript">
$(window).load(function() {
startProgress();
});
function startProgress(){
var pid = document.getElementsByClassName('ui-progressbar');
var pidLength = pid.length;
for (var i = 0; i < pidLength; i++) {
var id = "formExecutions:scroller:".concat(i).concat(":progressBar");
PrimeFaces.getWidgetById(id).start();
}
}
</script>
And that was all!
I'm newbie in Java and PrimeFaces (I have worked only with c# and visual sudio).
When I try to edit a row, column value isn't displayed in modal dialog.
I've tried different solution, same result.
Can someone help me?
<ui:include src="/includes/header.xhtml" />
<!-- Container -->
<div id="container">
<div class="shell">
<div id="main" style="vertical-align: middle;">
<br /> <br />
<form>
<p:dataTable var="loc" value="#{location.loc}" rowKey="#{loc.code}" id='loca'>
<p:column width="100">
<p:commandButton icon="ui-icon-plus" type="button" id="add" onclick="PF('newDialog').show()" update="Newform:NewLocation"/>
<p:commandButton icon="ui-icon-pencil" type="button" update="updForm:updDisplay" onclick="PF('updDialog').show()" id="edit" ajax="true">
</p:commandButton>
<p:commandButton icon="ui-icon-trash" />
</p:column>
<p:column headerText="Code">
<h:outputText value="#{loc.code}" />
</p:column>
<p:column headerText="Ip">
<h:outputText value="#{loc.address}" />
</p:column>
<p:column headerText="Descrizione">
<h:outputText value="#{loc.description}" />
</p:column>
</p:dataTable>
</form>
<p:dialog widgetVar="newDialog" header="Insert Location" width="430" height="220" modal="true">
<h:form id="Newform">
<p:outputPanel id="NewLocation">
<h:panelGrid columns="2">
<h:outputLabel value="Code" />
<p:inputText value="#{loc.Code}"></p:inputText>
<h:outputLabel value="description" />
<p:inputText value="#{loc.description}"></p:inputText>
<h:outputLabel value="Address" />
<p:inputText value="#{loc.address}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Save" onclick="newDialog.close()">
</p:commandButton>
</p:outputPanel>
</p:dialog>
<p:dialog widgetVar="updDialog" header="Location" width="430" height="220" modal="true">
<h:form id="updForm">
<p:outputPanel id="updDisplay">
<h:inputHidden value="#{loc.code}" />
<h:panelGrid columns="2">
<h:outputLabel value="Description" />
<p:inputText value="#{loc.description}"></p:inputText>
<h:outputLabel value="Address" />
<p:inputText value="#{loc.address}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Update" onclick="updDialog.close()">
</p:commandButton>
<p:commandButton value="Delete" onclick="updDialog.close()">
</p:commandButton>
<p:growl id="growl" showDetail="true" />
</p:outputPanel>
</h:form>
</p:dialog>
MangedBean:
#ManagedBean (name="Locations")
#SessionScoped
public class Locations {
#EJB
cslocationBeanRemote locationsBean;
private List<cslocationModel> ListLocations;
#SuppressWarnings({"unchecked", "rawtypes"})
#PostConstruct
public void init() {}
public List<cslocationModel> getListLocations() {
try {
ArrayList orderBy = new ArrayList();
orderBy.add(cslocationModel.ORDERcodASC);
setListLocations((List<cslocationModel>) locationsBean.find(null,
null, null, orderBy));
} catch (Exception ecc) {
ecc.printStackTrace();
}
return ListLocations;
}
public void setListLocations(List<cslocationModel> ListLocations) {
this.ListLocations = ListLocations;
}
}
Thank you.
In my JSF application, Primefaces autocomplete itemSelect event is not fired. I double checked and it is inside a form element. I can not figure out why it is not fired.
I have listed code below.
<p:panelGrid columns="1" >
<p:outputLabel value="Medicine/Device" ></p:outputLabel>
<p:autoComplete forceSelection="true" id="acStock" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.stock}" converter="stockCon" completeMethod="#{pharmacySaleController.completeAvailableStocks}" var="i" itemLabel="#{i.itemBatch.item.name}" itemValue="#{i}" >
<p:column headerText="Item">
<h:outputLabel value="#{i.itemBatch.item.name}" ></h:outputLabel>
</p:column>
<p:column headerText="Rate">
<h:outputLabel value="#{i.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
</h:outputLabel>
</p:column>
<p:column headerText="Stocks">
<h:outputLabel value="#{i.stock}" >
<f:convertNumber pattern="#,###" ></f:convertNumber>
</h:outputLabel>
</p:column>
<p:column headerText="Expiary">
<h:outputLabel value="#{i.itemBatch.dateOfExpire}" >
<f:convertDateTime pattern="MMM yyyy" ></f:convertDateTime>
</h:outputLabel>
</p:column>
<p:ajax event="query" update="lstSelectItems" ></p:ajax>
<p:ajax event="itemSelect" listener="#{pharmacySaleController.handleSelect}" update="txtRate txtQty txtVal" ></p:ajax>
</p:autoComplete>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Quentity" ></p:outputLabel>
<p:inputText id="txtQty" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.qty}" >
</p:inputText>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Rate" ></p:outputLabel>
<p:inputText id="txtRate" value="#{pharmacySaleController.billItem.rate}" >
</p:inputText>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Value" ></p:outputLabel>
<p:inputText id="txtVal" value="#{pharmacySaleController.billItem.netValue}" >
</p:inputText>
</p:panelGrid>
<p:commandButton value="Add" action="#{pharmacySaleController.addBillItem()}" ></p:commandButton>
</p:panelGrid>
Controller
public void handleSelect(SelectEvent event){
calculateRates();
}
public void calculateRates() {
System.out.println("calculating rates");
if (bill == null) {
System.out.println("bill is null");
return;
}
if (billItem == null) {
System.out.println("billItem is null");
return;
}
if (billItem.getPharmaceuticalBillItem() == null) {
System.out.println("pharmaceutical bill item is null");
return;
}
if (billItem.getPharmaceuticalBillItem().getStock() == null) {
System.out.println("billItem.getPharmaceuticalBillItem().getStock() = " + billItem.getPharmaceuticalBillItem().getStock());
return;
}
System.out.println("cal error check finished");
//
System.out.println("billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate() = " + billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
billItem.setRate(billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
billItem.setDiscountRate(calculateBillItemDiscountRate(billItem));
billItem.setNetRate(billItem.getRate() - billItem.getDiscountRate());
billItem.setGrossValue(billItem.getRate() * billItem.getQty());
billItem.setDiscount(billItem.getDiscountRate() * billItem.getQty());
billItem.setNetValue(billItem.getNetRate() * billItem.getQty());
}
I'm use Primefaces and trying to create infoWindow with different content for different types of overlays.
Map.java
public void onMarkerSelect(OverlaySelectEvent event) {
if (event.getOverlay() instanceof Marker) {
selectedOverlay = "marker";
selMarkerSite = (Site) event.getOverlay().getData();
selMarkerSiteNetworkElements = new ArrayList<NetworkElement>();
List<NetworkElement> neList = selMarkerSite.getNetworkElements();
if (!neList.isEmpty()) {
for (NetworkElement ne : neList) {
if (!(ne.getNeFunc().getName().equals("CELL2G") || ne.getNeFunc().getName().equals("CELL3G") || (ne.getNeStatus() != null && ne.getNeStatus().getId().equals(new BigDecimal(26))))
&& filter.getRadioType().contains(ne.getNeFunc().getGeneration())) {
selMarkerSiteNetworkElements.add(ne);
}
}
}
balloonText = HtmlFormatter.siteBalloonInfoFormater(selMarkerSite);
}
if (event.getOverlay() instanceof Polygon) {
selectedOverlay = "polygon";
// my code
}
}
jsf
<p:gmap center="#{map.center}"
zoom="#{map.zoom}" fitBounds="false" type="HYBRID" id="mainMapId"
style="width:100%; height:100%" widgetVar="mainMap"
model="#{map.mapModel}">
<p:ajax event="overlaySelect" listener="#{map.onMarkerSelect}" />
<p:ajax event="stateChange" listener="#{map.onStateChange}"
global="false"/>
/>
<p:gmapInfoWindow>
<p:panel rendered="#{map.selectedOverlay=='marker'}">
<h:panelGrid columns="2" width="580">
<p:column style="width:200px">
<p:outputPanel style="display:block; width:180px">
<h:outputText value="#{map.balloonText}" escape="false" />
<h:panelGrid columns="2" style="width:180px">
<p:commandLink id="getAlarmsForSite"
actionListener="#{map.getSiteAlarms}">
<h:outputText value="Alarms" />
</p:commandLink>
<p:commandLink id="editSiteOnMapBtn"
actionListener="#{map.editSite()}">
<f:setPropertyActionListener
target="#{createOrUpdateSiteDialogController.componentsToUpdateOnNetworkElementSelectListener}"
value=":updateOrCreateNetworkElementDialogId" />
<h:outputText value="Edit this Site" />
</p:commandLink>
</h:panelGrid>
</p:outputPanel>
</p:column>
<p:column style="width:380px">
<p:tabView id="tabView" var="NE"
value="#{map.selMarkerSiteNetworkElements}"
rendered="#{map.selMarkerSiteNetworkElements.size()>0}">
<p:tab id="neTab" title="#{NE.name}"
titleStyleClass="tabSev#{NE.minSeverity}">
<h:panelGrid columns="2" style="width: 420px;">
<h:panelGrid columns="2" style="width: 230px;">
<h:outputText value="MO: " style="font-weight: bold" />
<h:outputText value="#{NE.managingElement.name}" />
<h:outputText value="DN: " style="font-weight: bold" />
<h:outputText value="#{NE.dn}" />
<h:outputText value="TYPE: " style="font-weight: bold" />
<h:outputText value="#{NE.neFunc.name}" />
<h:outputText value="STATUS: " style="font-weight: bold" />
<h:outputText value="#{NE.neStatus.nameEng}" />
<h:outputText value="Customer " style="font-weight: bold" />
<p:graphicImage width="18" cache="true"
title="#{NE.nms.customer.nameEng}"
url="#{NE.nms.customer.labelSmall}"
style="padding-top: 2px;" />
<p:commandLink id="getAlarmsForNE"
actionListener="#{map.getBsAlarms(NE)}">
<h:outputText
value="Alarms (#{NE.sizeAlarmsWithChildrenNE})"
styleClass="sev#{NE.minSeverity}" />
</p:commandLink>
<p:commandLink id="editNeOnMapBtn"
actionListener="#{map.editNe(NE)}">
<h:outputText value="Edit this NE" />
<f:setPropertyActionListener
target="#{createOrupdateNetworkElementController.componentsToUpdateOnSiteViweActionListener}"
value=":updateOrCreateSiteDialogId" />
</p:commandLink>
</h:panelGrid>
<p:dataList value="#{NE.networkElements}" var="NEc"
rendered="#{NE.networkElements.size()>0}">
<h:outputText
value="name: #{NEc.name}; azimuth: #{NEc.azimuth!=null ? NEc.azimuth : '-' }" />
</p:dataList>
</h:panelGrid>
</p:tab>
</p:tabView>
</p:column>
</h:panelGrid>
</p:panel>
<p:panel rendered="#{map.selectedOverlay=='polygon'}">
//
</p:panel>
</p:gmapInfoWindow>
</p:gmap>
The troubleis that the infoWindow is not showed when i click on any overlay except marker.
I want use jsf code in infoWindow.
How i can show infoWindow for another overlays?