Currently Iam facing an issue with the primefaces P:TreeTable.
I have a p:treetable with edit . When I click on the pencil (Edit) icon and entered the value in the editable fields, Iam performing some validations in the managed bean. If any validation failed i need to show errormessage under the inputText in the treetable Row.
But the problem is, when I enter the value in the inputText and clicl on the check icon , Immediately check and cancel icons are gone and edit icon is appearing.when I again click on the pencil icon , then iam seeing that error message under that inputText.
But what I need is when I give value in inputText and I click on the check icon i need to see the error message immediately if validation error occurs.
Code: Select all
<p:treeTable value="#{manageExclusionsOverviewBean.treeNode}"
styleClass="treetableStyle" var="exclusion"
id="exclusionOverViewTreeId" editable="true">
<p:ajax event="rowEditInit" />
<p:ajax event="rowEditCancel" />
<p:ajax event="rowEdit"
listener="#{manageExclusionsOverviewBean.requestModifyExclusion(exclusion)}"
process="exclusionOverviewFormId:exclusionOverViewTreeId"
update="myErrorMessages " />
<p:column headerText="#{msgs['label.key']}"
styleClass="plusIconStyle" style="width:10%;text-align:center;">
<h:outputText value="#{exclusion.keyCode}" />
</p:column>
<p:column headerText="#{msgs['label.businessUnit']}"
style="width:12%;text-align:center;">
<h:outputText value="#{exclusion.businessUnit}" />
</p:column>
<p:column headerText="#{msgs['label.orderPickBeforeOrAfter']}"
style="width:22%;text-align:center;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{exclusion.beforeOrAfter}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{exclusion.beforeOrAfter}" maxlength="1"
id="beforeAfterId"
validator="#{manageExclusionsOverviewBean.validateBeforeAfterValue}"
style="width:100%" />
<p:message for="beforeAfterId"></p:message>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msgs['label.orderPickingGroup']}"
style="width:15%;text-align:center;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{exclusion.orderPickingGroupNum}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{exclusion.orderPickingGroupNum}"
id="orderPickGRPNUM" style="width:100%" maxlength="1"
validator="#{manageExclusionsOverviewBean.validateOrderPickingGroupNum}"
onkeypress="if(event.which < 48 || event.which > 57) return false;" />
<p:message for="orderPickGRPNUM"></p:message>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msgs['label.BLS']}"
style="width:7%;text-align:center;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{exclusion.blsType}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{exclusion.blsType}" maxlength="4"
validator="#{manageExclusionsOverviewBean.validateBLSValue}"
style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msgs['label.fromDate']}"
style="width:12%;text-align:center;"
sortBy="#{exclusion.dateFrom}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{exclusion.dateFrom}">
<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar value="#{exclusion.dateFrom}" pattern="dd/MM/yyyy"
style="width:100%" mask="true"></p:calendar>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msgs['label.toDate']}"
style="width:12%;text-align:center;" sortBy="#{exclusion.dateTo}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{exclusion.dateTo}">
<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar value="#{exclusion.dateTo}" pattern="dd/MM/yyyy"
timeZone="cet" style="width:100%" mask="true"></p:calendar>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:12%;text-align:center;">
<p:rowEditor rendered="#{exclusion.isEditable == true}"
style="float:left;" />
<p:commandButton icon="ui-icon-trash" style="width:35px;"
process="@form" update="@form"
actionListener="#{manageExclusionsOverviewBean.requestDelete(exclusion)}">
<p:confirm header="Confirmation" message="Are you sure?"
icon="ui-icon-alert" />
</p:commandButton>
</p:column>
</p:treeTable>
public void validateBeforeAfterValue(FacesContext context,
UIComponent component, Object value) throws ValidatorException {
System.out.println("in validateBeforeAfterValue");
String beforeAfter = (String) value;
if (!beforeAfter.equalsIgnoreCase("A")
&& !beforeAfter.equalsIgnoreCase("V")) {
MessageUtil.addFacesMessage(WebConstants.REQUIRED_FILEDS,
WebConstants.MESSAGE_PACKAGE, FacesMessage.SEVERITY_ERROR,
false, component.getClientId(), null);
System.out.println("client id is: " + component.getClientId());
RequestContext
.getCurrentInstance()
.update("exclusionOverviewFormId:exclusionOverViewTreeId:0_0:beforeAfterId");
throw new ValidatorException(new FacesMessage());
}
}