I have a requirement that on focus, need to update one component and on value change, need to execute some logic and update some other component. But always only first event is getting triggered.
<p:inputText id="text1" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" render="comp2"/>
</p:inputText>
<p:inputText id="text2" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" render="comp2"/>
</p:inputText>
<p:inputText id="comp1"/>
<p:inputText id="comp2"/>
tried with two p:ajax tags instead of f:ajax
tried with one p:ajax and one f:ajax, but same issue
Any help would be really appreciated.
Multiple p:ajax or f:ajax events for same component
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
My response/recommendations:
1. See my signature, and either display your development/test environment details in signature, so the community can respond accordingly, or reply with those details.
2. Please reply with your bean code, and please use the Code button above the editor, while responding, and paste your code in the Code tags.
1. See my signature, and either display your development/test environment details in signature, so the community can respond accordingly, or reply with those details.
2. Please reply with your bean code, and please use the Code button above the editor, while responding, and paste your code in the Code tags.
3. did you (forget to) add value="#{bean.attribute}" to the p:inputText below?Manimld5 wrote:I have a requirement that on focus, need to update one component and on value change, need to execute some logic and update some other component. But always only first event is getting triggered.
4. render="..." will definitely update the components on the page after AJAX response; hmmm, i wonder if you need to add process="..." to your p:ajax or similar for f:ajax tagsManimld5 wrote: <p:inputText id="comp1"/>
<p:inputText id="comp2"/>
Please respond to all i mentioned above, so I can further advise.Manimld5 wrote: <p:inputText id="text1" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" render="comp2"/>
</p:inputText>
<p:inputText id="text2" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" render="comp2"/>
</p:inputText>
tried with two p:ajax tags instead of f:ajax
tried with one p:ajax and one f:ajax, but same issue
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
Below are the details about my enviroment and code.
1. Rational Application Developer 8.0, Websphere Application Server 7.0, Java EE 6, Primefaces 2.2.1, Mojarra 2.0.3
2. Below is my code bean
my page is
it is always calling change event and focus is not getting called.
1. Rational Application Developer 8.0, Websphere Application Server 7.0, Java EE 6, Primefaces 2.2.1, Mojarra 2.0.3
2. Below is my code bean
Code: Select all
@ManagedBean
@ViewScoped
public class MyBean
{
private String textValue;
private String comp1Value;
private String comp2Value;
public void onChange(){
comp1Value = "on change triggered";
}
public void onFocus(){
comp2Value = "on fous triggered";
}
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public String getComp1Value() {
return comp1Value;
}
public void setComp1Value(String comp1Value) {
this.comp1Value = comp1Value;
}
public String getComp2Value() {
return comp2Value;
}
public void setComp2Value(String comp2Value) {
this.comp2Value = comp2Value;
}
}
Code: Select all
<h:form>
<h:panelGrid>
<p:inputText id="text1" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" execute="@this" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" execute="@this" render="comp2"/>
</p:inputText>
<p:inputText id="text2" value="#{myBean.textValue}">
<f:ajax event="change" listener="#{myBean.onChange}" execute="@this" render="comp1"/>
<f:ajax event="focus" listener="#{myBean.onFocus}" execute="@this" render="comp2"/>
</p:inputText>
<p:inputText id="comp1" value="#{myBean.comp1Value}"/>
<p:inputText id="comp2" value="#{myBean.comp2Value}"/>
</h:panelGrid>
</h:form>
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
1. Okay, you're using PrimeFaces 2.2.1
stackoverflow jsf f:ajax event="focus"
3. This post below seems to be similar to your post/issue/configuration. Please read the initial post on the page and look for BalusC's answer/response.
http://stackoverflow.com/questions/4353 ... aces-2-0-2
4. I tell everyone that BalusC answers so many JSF questions for the last 3 to 4 years, maybe more. He has a blogspot, too. Include "balusc jsf" in your google searches, when you are searching for an answer. Also, if you want to search specific site, like this site, google "forum.primefaces.org ..." where ... is what your'e searching for.
2. I googled the following:Rational Application Developer 8.0, Websphere Application Server 7.0, Java EE 6, Primefaces 2.2.1, Mojarra 2.0.3
stackoverflow jsf f:ajax event="focus"
3. This post below seems to be similar to your post/issue/configuration. Please read the initial post on the page and look for BalusC's answer/response.
http://stackoverflow.com/questions/4353 ... aces-2-0-2
4. I tell everyone that BalusC answers so many JSF questions for the last 3 to 4 years, maybe more. He has a blogspot, too. Include "balusc jsf" in your google searches, when you are searching for an answer. Also, if you want to search specific site, like this site, google "forum.primefaces.org ..." where ... is what your'e searching for.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
-
- Information
-
Who is online
Users browsing this forum: Google [Bot] and 38 guests