xhtml:
Code: Select all
<p:dialog
width="800"
id="templateDialog"
widgetVar="templateBox"
header="Choose Template"
closable="false"
modal="true"
draggable="true"
showEffect="clip"
hideEffect="fade"
resizable="false"
dynamic="true"
visible="#{manageWorkflowBean.templateDialogVisible}">
<h:form id="templateForm">
<p:messages
autoUpdate="false"
globalOnly="true"
closable="true"
showDetail="false" />
<p:dataTable
id="templateTable"
var="templateItem"
lazy="true"
rowKey="#{templateItem.templateId}"
value="#{manageWorkflowBean.templates}"
widgetVar="templateTable"
emptyMessage="No Rows Found"
rows="10"
paginator="true"
paginatorAlwaysVisible="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15,25"
tableStyleClass="usertable"
selection="#{manageWorkflowBean.selectedTemplate}">
<p:column
headerText="Select"
selectionMode="single">
</p:column>
<p:column
headerText="Template Name"
style="text-align:left;">
<h:outputText value="#{templateItem.templateName}" />
</p:column>
<p:column
headerText="Agency"
style="text-align:left;">
<h:outputText value="#{templateItem.agency}" />
</p:column>
</p:dataTable>
<br/>
<div
id="templateButtons"
style="margin: auto; text-align: center">
<p:commandButton
id="selectButton"
value="Apply Template"
actionListener="#{manageWorkflowBean.selectTemplate}"
process="@form"
update=":wfForm:selectedTemplateLabel templateForm" />
<p:commandButton
id="cancelButton"
value="#{labels['cancel']}"
process="@this"
update="@form"
immediate="true"
actionListener="#{manageWorkflowBean.cancelSelectTemplate}"
oncomplete="PF('templateBox').hide()">
<p:resetInput target=":wfForm:selectedTemplateLabel"></p:resetInput>
</p:commandButton>
</div>
</h:form>
</p:dialog>
Code: Select all
public void selectTemplate(ActionEvent event) {
if (this.selectedTemplate == null) {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(
FacesMessage.SEVERITY_ERROR, "A template must be selected", ""));
FacesContext.getCurrentInstance().renderResponse();
return;
} else {
this.selectedTemplateName = this.selectedTemplate.getTemplateName();
this.templateDialogVisible = false;
}
}