Hello
I have the following problem. I have the inputText description which is disabled by default. When I click the browse button, it enables inputText and then instantiates an object to search. If I do not pass a filter in the inputText description, it searches all the records of the object I'm using, if I pass a filter it brings the records according to the reported filter. In my class I have a @NotNull annotation in the description property, to treat the validation in the register screen, however to avoid that the inputText is validated at the time of searching without any filter, I am using in my commandButton the process="@ this" but if I pass a filter, this filter is not being "set" in the description property of my object and is always searching all records.
How do I handle this situation? If I remove the note from my property the logic works correctly, but if I use it I get this problem.
I'm using the Bean Validations annotations so I do not have to do a validation within my bean creating a series of if and else, with Bean Validations I believe I'll be handling validations at the right phase of the lifecycle. >
Page Codes!
Template CRUD basic.xhtml (Code 1)
<!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:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:head>
<title>${titulo}</title>
<h:outputStylesheet name="core.js" target="head" library="js" />
<h:outputStylesheet name="style.css" target="head" library="css" />
</h:head>
<h:body>
<div id="dvStatus" align="center">
<p:ajaxStatus onstart="PF('statusDialog').show();" onsuccess="PF('statusDialog').hide();" />
<p:dialog modal="true" widgetVar="statusDialog" draggable="false" closable="false" resizable="false" showHeader="false">
<p:graphicImage value="/resources/img/icon/ajaxloading3.gif" />
</p:dialog>
</div>
<h:form id="formCrud">
<ui:insert name="cabecalho">
<ui:include src="tmenu.xhtml" />
</ui:insert>
<p:toolbar/>
<ui:insert name="toolbar">
<p:toolbar id="tool">
<p:toolbarGroup>
<ui:insert name="toolbarButtons" />
</p:toolbarGroup>
</p:toolbar>
</ui:insert>
<ui:insert name="panelExterno">
<ui:insert name="panelCentral" />
<center>
<h:messages id="growl" showDetail="true" autoUpdate="true" closable="true" showSummary="false" errorClass="converterMsgError" warnClass="converterMsgWarn" infoClass="converterMsgInfo" fatalClass="converterMsgError" />
</center>
</ui:insert>
<p:confirmDialog global="true">
<p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="confirm" />
<p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="cancel" />
</p:confirmDialog>
</h:form>
</h:body>
</html>
Template CRUD crud.xhtml (Code 2)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" template="/templates/basic.xhtml">
<ui:define name="toolbarButtons">
<ui:insert name="btnNew">
<p:commandButton id="new" value="Novo" actionListener="#{backingBean.novo}" update="tool pnlCampos growl" disabled="#{backingBean.disableBtnNew}" icon="novo" style="width:100px; margin-left: 6px;" />
</ui:insert>
<ui:insert name="btnSave">
<p:commandButton id="save" value="Salvar" actionListener="#{backingBean.salvar}" update="tool pnlCampos pnlTable growl" disabled="#{backingBean.disableBtnSave}" icon="gravar" style="width:100px;margin-left: 6px;" />
</ui:insert>
<ui:insert name="btnCancel">
<p:commandButton id="cancel" value="Cancelar" actionListener="#{backingBean.cancelar}" process="@this" update="tool pnlCampos pnlTable growl" disabled="#{backingBean.disableBtnCancel}" icon="cancel" style="width:100px;margin-left: 6px;" />
</ui:insert>
<ui:insert name="btnFind">
<p:commandButton id="search" value="Pesquisar" actionListener="#{backingBean.pesquisar}" process="@this pnlCampos" update="tool pnlCampos pnlTable growl" disabled="#{backingBean.disableBtnSearch}" icon="search" style="width:100px;margin-left: 6px;" />
</ui:insert>
<ui:insert name="btnExport" />
<ui:insert name="toolbarExtraButtons" />
</ui:define>
<ui:define name="panelCentral">
<ui:insert name="panelDeCadastro">
<p:panel id="pnlCampos" header="${toolTitulo}">
<ui:insert name="panelCadastro" />
</p:panel>
</ui:insert>
<ui:insert name="table">
<p:outputPanel id="pnlTable" deferred="true">
<p:dataTable id="table" value="#{backingBean.model}" var="obj" rows="8" paginator="true" paginatorPosition="bottom" emptyMessage="" rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'even-row' : 'odd-row'}" rowIndexVar="rowIx" scrollable="true">
<f:facet name="header">
Registro(s) Cadastrado(s)
</f:facet>
<ui:insert name="colunasTabela" />
<p:column id="edit" style="width: 10px; text-align:center;">
<p:commandLink title="Editar Registro" actionListener="#{backingBean.editar}" process="@this" update=":formCrud:pnlCampos :formCrud:tool :formCrud:pnlTable :formCrud:growl">
<p:graphicImage value="/resources/img/icon/editar_16x16.png" />
</p:commandLink>
</p:column>
<p:column id="del" style="width: 10px; text-align:center;">
<p:commandLink title="Deletar Registro" actionListener="#{backingBean.excluir}" process="@this" update=":formCrud:pnlCampos :formCrud:tool :formCrud:pnlTable :formCrud:growl">
<p:graphicImage value="/resources/img/icon/excluir_16x16.png" />
<f:setPropertyActionListener target="#{backingBean.rowData}" value="#{obj}" />
<p:confirm header="Atenção" message="Você confirma a exclusão desse registro ?" icon="ui-icon-alert" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:outputPanel>
</ui:insert>
</ui:define>
</ui:composition>
Job Title Screen (Code 3)
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/templates/crud.xhtml">
<ui:param name="titulo" value="Tela de Cargo" />
<ui:param name="toolTitulo" value="Cadastro e Edição de Cargo" />
<ui:param name="backingBean" value="#{cargoBean}" />
<ui:define name="panelCadastro">
<h:panelGrid id="pnlGrdCargo" columns="1" width="100%">
<h:outputText value="Descrição:" />
<p:inputText value="#{cargoBean.domain.descricao}" onkeyup="this.value = this.value.toUpperCase()" disabled="#{cargoBean.disabledOnDefault}" style="width: 30%;" />
</h:panelGrid>
</ui:define>
<ui:define name="colunasTabela">
<p:column headerText="Código" style="width: 50px;">
<h:outputText value="#{obj.codigoCargoFuncionario}" />
</p:column>
<p:column headerText="Descrição">
<h:outputText value="#{obj.descricao}" />
</p:column>
</ui:define>
</ui:composition>
</html>
Thank you!