You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Ricard Moré (JIRA)" <de...@myfaces.apache.org> on 2012/09/19 11:24:07 UTC

[jira] [Created] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Ricard Moré created MYFACES-3611:
------------------------------------

             Summary: Validator method fired N times for ajax action if there's a binding attribute
                 Key: MYFACES-3611
                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 2.1.2
         Environment: Tomcat 7, windows
            Reporter: Ricard Moré


There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
<h:form id="form">
	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
	binding="#{controles.textComponent}"/>		
	<br/><br/>
	<h:commandButton value="validate">
		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
	</h:commandButton>
</h:form>

And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Posted by "Ricard Moré (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458527#comment-13458527 ] 

Ricard Moré commented on MYFACES-3611:
--------------------------------------

I just realized that it happens too for a standar (non ajax) actionListener.
                
> Validator method fired N times for ajax action if there's a binding attribute
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-3611
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.2
>         Environment: Tomcat 7, windows
>            Reporter: Ricard Moré
>
> There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
> <h:form id="form">
> 	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
> 	binding="#{controles.textComponent}"/>		
> 	<br/><br/>
> 	<h:commandButton value="validate">
> 		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
> 	</h:commandButton>
> </h:form>
> And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Posted by "Mike Kienenberger (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458827#comment-13458827 ] 

Mike Kienenberger edited comment on MYFACES-3611 at 9/20/12 3:36 AM:
---------------------------------------------------------------------

You might also be able to return null in controles.getTextComponent() and accomplish the same thing without having to make another bean or change scope.   My guess is that you only want a reference to the component, and you are not trying to create a new component.

public UIComponent getTextComponent() { return null; }

http://drewdev.blogspot.com/2009/01/jsf-component-binding-stinks.html

                
      was (Author: mkienenb):
    You might also be able to return null in controles.getTextComponent() and accomplish the same thing.   My guess is that you only want a reference to the component, and you are not trying to create a new component.

public UIComponent getTextComponent() { return null; }

http://drewdev.blogspot.com/2009/01/jsf-component-binding-stinks.html

                  
> Validator method fired N times for ajax action if there's a binding attribute
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-3611
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.2
>         Environment: Tomcat 7, windows
>            Reporter: Ricard Moré
>
> There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
> <h:form id="form">
> 	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
> 	binding="#{controles.textComponent}"/>		
> 	<br/><br/>
> 	<h:commandButton value="validate">
> 		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
> 	</h:commandButton>
> </h:form>
> And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Posted by "Ricard Moré (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459634#comment-13459634 ] 

Ricard Moré commented on MYFACES-3611:
--------------------------------------

Thanks Mike. It works fine now, without making a second bean. Issue closed.
                
> Validator method fired N times for ajax action if there's a binding attribute
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-3611
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.2
>         Environment: Tomcat 7, windows
>            Reporter: Ricard Moré
>
> There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
> <h:form id="form">
> 	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
> 	binding="#{controles.textComponent}"/>		
> 	<br/><br/>
> 	<h:commandButton value="validate">
> 		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
> 	</h:commandButton>
> </h:form>
> And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458754#comment-13458754 ] 

Leonardo Uribe commented on MYFACES-3611:
-----------------------------------------

That's symptom that you are using a session scope bean to hold the binding, which is invalid. Split your bean in two and move the binding to a request scope bean should solve the problem.
                
> Validator method fired N times for ajax action if there's a binding attribute
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-3611
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.2
>         Environment: Tomcat 7, windows
>            Reporter: Ricard Moré
>
> There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
> <h:form id="form">
> 	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
> 	binding="#{controles.textComponent}"/>		
> 	<br/><br/>
> 	<h:commandButton value="validate">
> 		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
> 	</h:commandButton>
> </h:form>
> And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MYFACES-3611) Validator method fired N times for ajax action if there's a binding attribute

Posted by "Mike Kienenberger (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458827#comment-13458827 ] 

Mike Kienenberger commented on MYFACES-3611:
--------------------------------------------

You might also be able to return null in controles.getTextComponent() and accomplish the same thing.   My guess is that you only want a reference to the component, and you are not trying to create a new component.

public UIComponent getTextComponent() { return null; }

http://drewdev.blogspot.com/2009/01/jsf-component-binding-stinks.html

                
> Validator method fired N times for ajax action if there's a binding attribute
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-3611
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3611
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.2
>         Environment: Tomcat 7, windows
>            Reporter: Ricard Moré
>
> There's a problem in the validation phase when you mix ajax action and a binding value in the same form. For example I have this simple form:
> <h:form id="form">
> 	<h:inputText id="text" value="#{controles.text}" validator="#{controles.validateText}" 
> 	binding="#{controles.textComponent}"/>		
> 	<br/><br/>
> 	<h:commandButton value="validate">
> 		<f:ajax event="click" render="text" listener="#{controles.clearText}" execute="@form" immediate="false"/>
> 	</h:commandButton>
> </h:form>
> And when validate button is clicked the validator method validateText is called twice the first time, 3 times for the second submit and one more time each time the ajax action is fired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira