Ok, here you are the main problem.
Page. I have two required "text input". A command button that changes the value of a bean and resets the job object.
<a4j:form id="pervForm"> SURNAME:<h:inputText id="surname" label="Surname" value="#{prevManager.surname}" required="true" /> <br/> JOB:<h:inputText value="#{prevManager.job}" id="job" maxlength="10" size="10" label="#{msg.common_label_job}" required="true" /> <br/> <a4j:commandButton value="Set job to Programmer" ajaxSingle="true" reRender="job"> <a4j:actionparam name="jVal" value="Programmer" assignTo="#{prevManager.job}"/> </a4j:commandButton> <h:commandButton id="save" value="save" action="save" class="HATSBUTTON"/> </a4j:form>
Here is a simple manager:
public class PrevManager { private String surname; private String job; public String getSurname() { return surname; } public void setSurname(String surname) { this.surname = surname; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } public String save() {
Do it:
Write something in the text of the assignment (for example, "teacher"). Leave an empty surname. Save. A verification error appears (last name is required). Click "Set task to programmer": nothing happens.
Checking the value of bean, I found that it was updated correctly, indeed, the component on the page does not update!
Ok, according to JBoss Docs, I found:
Ajax realm is a key component of ajax. It limits the part of the tree component that will be processed on the server when an ajax request arrives. Processing means a call during decryption, verification and updating of the model phase. The most common reasons for using an area:
- elimination of interruption of processing of the JSF life cycle during confirmation of input of another form is not required for a given ajax request; -definition of various strategies when events will be delivered (Immediate = true / false) -definition of an individual ajax status indicator - increase in rendering processing performance (SelfRendered = true / false, renderRegionOnly = "true / false")
The following two examples show situations where error validation does not allow ajax input to be processed. Enter your name. The output text of the component should appear after you. However, in the first case, this activity will be interrupted due to another field with required = "true". You will only see an error message while the "Job" field is empty.
Here is an example:
<ui:composition 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:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <style> .outergridvalidationcolumn { padding: 0px 30px 10px 0px; } </style> <a4j:outputPanel ajaxRendered="true"> <h:messages style="color:red" /> </a4j:outputPanel> <h:panelGrid columns="2" columnClasses="outergridvalidationcolumn"> <h:form id="form1"> <h:panelGrid columns="2"> <h:outputText value="Name" /> <h:inputText value="#{userBean.name}"> <a4j:support event="onkeyup" reRender="outname" /> </h:inputText> <h:outputText value="Job" /> <h:inputText required="true" id="job2" value="#{userBean.job}" /> </h:panelGrid> </h:form> <h:form id="form2"> <h:panelGrid columns="2"> <h:outputText value="Name" /> <a4j:region> <h:inputText value="#{userBean.name}"> <a4j:support event="onkeyup" reRender="outname" /> </h:inputText> </a4j:region> <h:outputText value="Job" /> <h:inputText required="true" id="job1" value="#{userBean.job}" /> </h:panelGrid> </h:form> </h:panelGrid> <h:outputText id="outname" style="font-weight:bold" value="Typed Name: #{userBean.name}" /> <br /> </ui:composition>
Form 1: The behavior is incorrect. I need to complete the task, and then the name. Form 2: The behavior is correct. I do not need to complete the task to see the correct value.
Unfortunately, using the Ajax scope does not help (indeed, I used it poorly) ... because my fields are both REQUIRED. This is the main thing else.
Any idea?
Thank you very much.