You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by raindogs <co...@yahoo.com> on 2007/03/08 21:26:04 UTC

Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

One other thing... it occurred to me that I could probably bypass any
complications from JSF validation by adding immediate="true" to the
"a4j:support" tag. The method did fire when I did this, but the elements
defined in "rerender" did not refresh. I'm sure the solution is in here
somewhere, but I'm just not seeing it.



raindogs wrote:
> 
> I'm having a problem getting ajax4jsf to play nice with jsf form
> validation. The page below uses ajax4jsf to run a method from the bean
> when the value in the "state" list changes and update a couple of fields.
> This works great under most circumstances. However, if the user submits
> the form *without* filling in the required "addressName" field, the form
> does not submit and the error message is displayed. This is as it should
> be. The trouble comes when, if the form has been submitted and is
> displaying the error message for the "addressName" field, the user changes
> the "state" field, which should still fire off the "loadState" method. In
> this case, the "loadState" method never fires and none of the fields in
> the "reRender" list are refreshed, even if there is now a value in the
> "addressname" field. The snippet below should show all of the relvant
> code, any help would be much appreciated.
> 
> Thanks,
> Alex
> 
> 
> <s:subForm id = "locationSubForm">
> <h:panelGroup id="locationGroup">
> 	<h:panelGrid columns="2" style="margin-top:10px;" id="locationGrid"
> border="0" cellpadding="2">
> 
> 			<h:outputText value="Address Name:" />
> 			<h:inputText id="addressName" value="#{locationForm.addressName}" 
> required="true"/>
> 			
> 			<h:message for="addressName" />
> 			<h:outputText value="" />
> 			 	
> 			<h:outputText value="Street Address:" /> 
> 			<h:inputText id="streetAddress" value="#{locationForm.streetAddress}"
> />
> 			 	
> 			<h:outputText value="City:" /> 
> 			<h:inputText id="city" value="#{locationForm.city}" />
> 			 	
> 			<h:outputText value="State:" /> 
> 
> 			<h:selectOneMenu value="#{locationForm.state}"
> style="padding:0px;margin:0px;">
> 				<a4j:support event="onchange" action="#{locationForm.loadState}"
> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/> 
> 				<f:selectItems value ="#{locationForm.stateList}" />
> 			</h:selectOneMenu>
> 
> 			...
> 
> 			<t:commandButton action="#{locationForm.submitNewLocation}"
> value="Submit" actionFor="locationSubForm"/>
> 			<h:outputText value="&nbsp;" escape="false"/>
> 		</h:panelGrid>
> 	</h:panelGroup>
> </s:subForm>
> 	
> 	
> 

-- 
View this message in context: http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9381466
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by raindogs <co...@yahoo.com>.
I just tried it with  t:messages with forceSpan="true". No luck there either.

I also ran an a4j:log and, surprisingly, it looks almost identical before
and after the failed validation. Despite the fact that the method does not
appear to fire (I used Eclipse to watch for a breakpoint), it is actually
getting the values and the Ajax log shows it updating the appropriate
elements. Unfortunately, the elements displayed on the screen remain the
same. It seems like the AJAX stuff is all working and that JSF is just
refusing to cooperate.

This is incredibly puzzling and frustrating. I am now moving past the
"careful debugging" phase and into the "curse at the screen, pound on the
walls, and frighten my co-workers" phase.

Alex








Cagatay Civici wrote:
> 
>>
>> The h:message/h:messages component is not rendering anything if there is
>> no error message and that's why it cannot be rerendered if there is an
>> error
>> message (this is the most possible reason for your action method not to
>> be
>> invoked).
> 
> 
> How about trying t:messages with forceSpan="true"
> 
> Cagatay
> 
> 
> On 3/9/07, Adrian Mitev <ad...@googlemail.com> wrote:
>>
>> Try with a4j:log and see what's printed there.
>>
>> 2007/3/9, raindogs <co...@yahoo.com>:
>> >
>> >
>> > Thanks for the response. I did put the <a4j:outputPanel
>> > ajaxRendered="true">
>> > around the h:message tags, but the problem persists. I also tried
>> adding
>> > the
>> > t:saveState to the values in the drop-down, but that didn't work
>> either.
>> >
>> >
>> > I also posted this to the Ajax4Jsf forum on the JBoss site, but anyone
>> > here
>> > who can think of another way around this will immediately earn a spot
>> on
>> > my
>> > Christmas card list.
>> >
>> >
>> >
>> >
>> > Adrian Mitev-2 wrote:
>> > >
>> > > The h:message/h:messages component is not rendering anything if there
>> > is
>> > > no
>> > > error message and that's why it cannot be rerendered if there is an
>> > error
>> > > message (this is the most possible reason for your action method not
>> > to be
>> > > invoked).
>> > > Nest the h:message tag into <a4j:outputPanel ajaxRendered="true">
>> like
>> > > this:
>> > >
>> > > <a4j:outputPanel ajaxRendered="true">
>> > >   <h:message for="addressName" />
>> > > </a4j:outputPanel>
>> > >
>> > >
>> > > 2007/3/8, Siju.Varghese@equifax.com <Si...@equifax.com>:
>> > >>
>> > >>
>> > >> I too had this problem, in my case the managed bean was in request
>> > scope.
>> > >> I did a t:saveState on the select item list and it solved the
>> > problem.
>> > >>
>> > >> -Siju
>> > >>
>> > >>
>> > >>
>> > >>  *Jeff Bischoff <jb...@klkurz.com>*
>> > >>
>> > >> 03/08/2007 03:33 PM  Please respond to
>> > >> "MyFaces Discussion" < users@myfaces.apache.org>
>> > >>
>> > >>   To
>> > >> MyFaces Discussion <us...@myfaces.apache.org>  cc
>> > >>
>> > >>  Subject
>> > >> Re: [Solved] ajax4jsf trouble after a form has failed JSF validation
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> Raindog,
>> > >>
>> > >> I would ask in the new ajax4jsf forum. See [1].
>> > >>
>> > >> [1] http://jboss.com/index.html?module=bb&op=viewforum&f=259
>> > >>
>> > >> raindogs wrote:
>> > >> > One other thing... it occurred to me that I could probably bypass
>> > any
>> > >> > complications from JSF validation by adding immediate="true" to
>> the
>> > >> > "a4j:support" tag. The method did fire when I did this, but the
>> > >> elements
>> > >> > defined in "rerender" did not refresh. I'm sure the solution is in
>> > here
>> > >> > somewhere, but I'm just not seeing it.
>> > >> >
>> > >> >
>> > >> >
>> > >> > raindogs wrote:
>> > >> >> I'm having a problem getting ajax4jsf to play nice with jsf form
>> > >> >> validation. The page below uses ajax4jsf to run a method from the
>> > bean
>> > >> >> when the value in the "state" list changes and update a couple of
>> > >> fields.
>> > >> >> This works great under most circumstances. However, if the user
>> > >> submits
>> > >> >> the form *without* filling in the required "addressName" field,
>> > the
>> > >> form
>> > >> >> does not submit and the error message is displayed. This is as it
>> > >> should
>> > >> >> be. The trouble comes when, if the form has been submitted and is
>> > >> >> displaying the error message for the "addressName" field, the
>> user
>> > >> changes
>> > >> >> the "state" field, which should still fire off the "loadState"
>> > method.
>> > >> In
>> > >> >> this case, the "loadState" method never fires and none of the
>> > fields
>> > >> in
>> > >> >> the "reRender" list are refreshed, even if there is now a value
>> in
>> > the
>> > >> >> "addressname" field. The snippet below should show all of the
>> > relvant
>> > >> >> code, any help would be much appreciated.
>> > >> >>
>> > >> >> Thanks,
>> > >> >> Alex
>> > >> >>
>> > >> >>
>> > >> >> <s:subForm id = "locationSubForm">
>> > >> >> <h:panelGroup id="locationGroup">
>> > >> >>                  <h:panelGrid columns="2"
>> style="margin-top:10px;"
>> > >> id="locationGrid"
>> > >> >> border="0" cellpadding="2">
>> > >> >>
>> > >> >>                                                    <h:outputText
>> > >> value="Address Name:" />
>> > >> >>                                                    <h:inputText
>> > >> id="addressName" value="#{locationForm.addressName}"
>> > >> >> required="true"/>
>> > >> >>
>> > >> >>                                                    <h:message
>> > >> for="addressName" />
>> > >> >>                                                    <h:outputText
>> > >> value="" />
>> > >> >>
>> > >> >>                                                    <h:outputText
>> > >> value="Street Address:" />
>> > >> >>                                                    <h:inputText
>> > >> id="streetAddress" value="#{locationForm.streetAddress}"
>> > >> >> />
>> > >> >>
>> > >> >>                                                    <h:outputText
>> > >> value="City:" />
>> > >> >>                                                    <h:inputText
>> > >> id="city" value="#{locationForm.city}" />
>> > >> >>
>> > >> >>                                                    <h:outputText
>> > >> value="State:" />
>> > >> >>
>> > >>
>> > >>                                                    <h:selectOneMenu
>> > >> value="#{locationForm.state}"
>> > >> >> style="padding:0px;margin:0px;">
>> > >> >>
>> > >> <a4j:support event="onchange" action="#{locationForm.loadState }"
>> > >> >> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/>
>> > >> >>
>> > >> <f:selectItems value ="#{locationForm.stateList}" />
>> > >>
>> > >>                                                   
>> </h:selectOneMenu>
>> > >> >>
>> > >> >>                                                    ...
>> > >> >>
>> > >>
>> > >>                                                    <t:commandButton
>> > >> action="#{locationForm.submitNewLocation}"
>> > >> >> value="Submit" actionFor="locationSubForm"/>
>> > >> >>                                                    <h:outputText
>> > >> value="" escape="false"/>
>> > >> >>                                   </h:panelGrid>
>> > >> >>                  </h:panelGroup>
>> > >> >> </s:subForm>
>> > >> >>
>> > >> >>
>> > >> >>
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >>
>> > >
>> > >
>> >
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9397483
>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9399790
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by Cagatay Civici <ca...@gmail.com>.
>
> The h:message/h:messages component is not rendering anything if there is
> no error message and that's why it cannot be rerendered if there is an error
> message (this is the most possible reason for your action method not to be
> invoked).


How about trying t:messages with forceSpan="true"

Cagatay


On 3/9/07, Adrian Mitev <ad...@googlemail.com> wrote:
>
> Try with a4j:log and see what's printed there.
>
> 2007/3/9, raindogs <co...@yahoo.com>:
> >
> >
> > Thanks for the response. I did put the <a4j:outputPanel
> > ajaxRendered="true">
> > around the h:message tags, but the problem persists. I also tried adding
> > the
> > t:saveState to the values in the drop-down, but that didn't work either.
> >
> >
> > I also posted this to the Ajax4Jsf forum on the JBoss site, but anyone
> > here
> > who can think of another way around this will immediately earn a spot on
> > my
> > Christmas card list.
> >
> >
> >
> >
> > Adrian Mitev-2 wrote:
> > >
> > > The h:message/h:messages component is not rendering anything if there
> > is
> > > no
> > > error message and that's why it cannot be rerendered if there is an
> > error
> > > message (this is the most possible reason for your action method not
> > to be
> > > invoked).
> > > Nest the h:message tag into <a4j:outputPanel ajaxRendered="true"> like
> > > this:
> > >
> > > <a4j:outputPanel ajaxRendered="true">
> > >   <h:message for="addressName" />
> > > </a4j:outputPanel>
> > >
> > >
> > > 2007/3/8, Siju.Varghese@equifax.com <Si...@equifax.com>:
> > >>
> > >>
> > >> I too had this problem, in my case the managed bean was in request
> > scope.
> > >> I did a t:saveState on the select item list and it solved the
> > problem.
> > >>
> > >> -Siju
> > >>
> > >>
> > >>
> > >>  *Jeff Bischoff <jb...@klkurz.com>*
> > >>
> > >> 03/08/2007 03:33 PM  Please respond to
> > >> "MyFaces Discussion" < users@myfaces.apache.org>
> > >>
> > >>   To
> > >> MyFaces Discussion <us...@myfaces.apache.org>  cc
> > >>
> > >>  Subject
> > >> Re: [Solved] ajax4jsf trouble after a form has failed JSF validation
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> Raindog,
> > >>
> > >> I would ask in the new ajax4jsf forum. See [1].
> > >>
> > >> [1] http://jboss.com/index.html?module=bb&op=viewforum&f=259
> > >>
> > >> raindogs wrote:
> > >> > One other thing... it occurred to me that I could probably bypass
> > any
> > >> > complications from JSF validation by adding immediate="true" to the
> > >> > "a4j:support" tag. The method did fire when I did this, but the
> > >> elements
> > >> > defined in "rerender" did not refresh. I'm sure the solution is in
> > here
> > >> > somewhere, but I'm just not seeing it.
> > >> >
> > >> >
> > >> >
> > >> > raindogs wrote:
> > >> >> I'm having a problem getting ajax4jsf to play nice with jsf form
> > >> >> validation. The page below uses ajax4jsf to run a method from the
> > bean
> > >> >> when the value in the "state" list changes and update a couple of
> > >> fields.
> > >> >> This works great under most circumstances. However, if the user
> > >> submits
> > >> >> the form *without* filling in the required "addressName" field,
> > the
> > >> form
> > >> >> does not submit and the error message is displayed. This is as it
> > >> should
> > >> >> be. The trouble comes when, if the form has been submitted and is
> > >> >> displaying the error message for the "addressName" field, the user
> > >> changes
> > >> >> the "state" field, which should still fire off the "loadState"
> > method.
> > >> In
> > >> >> this case, the "loadState" method never fires and none of the
> > fields
> > >> in
> > >> >> the "reRender" list are refreshed, even if there is now a value in
> > the
> > >> >> "addressname" field. The snippet below should show all of the
> > relvant
> > >> >> code, any help would be much appreciated.
> > >> >>
> > >> >> Thanks,
> > >> >> Alex
> > >> >>
> > >> >>
> > >> >> <s:subForm id = "locationSubForm">
> > >> >> <h:panelGroup id="locationGroup">
> > >> >>                  <h:panelGrid columns="2" style="margin-top:10px;"
> > >> id="locationGrid"
> > >> >> border="0" cellpadding="2">
> > >> >>
> > >> >>                                                    <h:outputText
> > >> value="Address Name:" />
> > >> >>                                                    <h:inputText
> > >> id="addressName" value="#{locationForm.addressName}"
> > >> >> required="true"/>
> > >> >>
> > >> >>                                                    <h:message
> > >> for="addressName" />
> > >> >>                                                    <h:outputText
> > >> value="" />
> > >> >>
> > >> >>                                                    <h:outputText
> > >> value="Street Address:" />
> > >> >>                                                    <h:inputText
> > >> id="streetAddress" value="#{locationForm.streetAddress}"
> > >> >> />
> > >> >>
> > >> >>                                                    <h:outputText
> > >> value="City:" />
> > >> >>                                                    <h:inputText
> > >> id="city" value="#{locationForm.city}" />
> > >> >>
> > >> >>                                                    <h:outputText
> > >> value="State:" />
> > >> >>
> > >>
> > >>                                                    <h:selectOneMenu
> > >> value="#{locationForm.state}"
> > >> >> style="padding:0px;margin:0px;">
> > >> >>
> > >> <a4j:support event="onchange" action="#{locationForm.loadState }"
> > >> >> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/>
> > >> >>
> > >> <f:selectItems value ="#{locationForm.stateList}" />
> > >>
> > >>                                                    </h:selectOneMenu>
> > >> >>
> > >> >>                                                    ...
> > >> >>
> > >>
> > >>                                                    <t:commandButton
> > >> action="#{locationForm.submitNewLocation}"
> > >> >> value="Submit" actionFor="locationSubForm"/>
> > >> >>                                                    <h:outputText
> > >> value="" escape="false"/>
> > >> >>                                   </h:panelGrid>
> > >> >>                  </h:panelGroup>
> > >> >> </s:subForm>
> > >> >>
> > >> >>
> > >> >>
> > >> >
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9397483
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>

Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by Adrian Mitev <ad...@googlemail.com>.
Try with a4j:log and see what's printed there.

2007/3/9, raindogs <co...@yahoo.com>:
>
>
> Thanks for the response. I did put the <a4j:outputPanel
> ajaxRendered="true">
> around the h:message tags, but the problem persists. I also tried adding
> the
> t:saveState to the values in the drop-down, but that didn't work either.
>
> I also posted this to the Ajax4Jsf forum on the JBoss site, but anyone
> here
> who can think of another way around this will immediately earn a spot on
> my
> Christmas card list.
>
>
>
>
> Adrian Mitev-2 wrote:
> >
> > The h:message/h:messages component is not rendering anything if there is
> > no
> > error message and that's why it cannot be rerendered if there is an
> error
> > message (this is the most possible reason for your action method not to
> be
> > invoked).
> > Nest the h:message tag into <a4j:outputPanel ajaxRendered="true"> like
> > this:
> >
> > <a4j:outputPanel ajaxRendered="true">
> >   <h:message for="addressName" />
> > </a4j:outputPanel>
> >
> >
> > 2007/3/8, Siju.Varghese@equifax.com <Si...@equifax.com>:
> >>
> >>
> >> I too had this problem, in my case the managed bean was in request
> scope.
> >> I did a t:saveState on the select item list and it solved the problem.
> >>
> >> -Siju
> >>
> >>
> >>
> >>  *Jeff Bischoff <jb...@klkurz.com>*
> >>
> >> 03/08/2007 03:33 PM  Please respond to
> >> "MyFaces Discussion" <us...@myfaces.apache.org>
> >>
> >>   To
> >> MyFaces Discussion <us...@myfaces.apache.org>  cc
> >>
> >>  Subject
> >> Re: [Solved] ajax4jsf trouble after a form has failed JSF validation
> >>
> >>
> >>
> >>
> >>
> >>
> >> Raindog,
> >>
> >> I would ask in the new ajax4jsf forum. See [1].
> >>
> >> [1] http://jboss.com/index.html?module=bb&op=viewforum&f=259
> >>
> >> raindogs wrote:
> >> > One other thing... it occurred to me that I could probably bypass any
> >> > complications from JSF validation by adding immediate="true" to the
> >> > "a4j:support" tag. The method did fire when I did this, but the
> >> elements
> >> > defined in "rerender" did not refresh. I'm sure the solution is in
> here
> >> > somewhere, but I'm just not seeing it.
> >> >
> >> >
> >> >
> >> > raindogs wrote:
> >> >> I'm having a problem getting ajax4jsf to play nice with jsf form
> >> >> validation. The page below uses ajax4jsf to run a method from the
> bean
> >> >> when the value in the "state" list changes and update a couple of
> >> fields.
> >> >> This works great under most circumstances. However, if the user
> >> submits
> >> >> the form *without* filling in the required "addressName" field, the
> >> form
> >> >> does not submit and the error message is displayed. This is as it
> >> should
> >> >> be. The trouble comes when, if the form has been submitted and is
> >> >> displaying the error message for the "addressName" field, the user
> >> changes
> >> >> the "state" field, which should still fire off the "loadState"
> method.
> >> In
> >> >> this case, the "loadState" method never fires and none of the fields
> >> in
> >> >> the "reRender" list are refreshed, even if there is now a value in
> the
> >> >> "addressname" field. The snippet below should show all of the
> relvant
> >> >> code, any help would be much appreciated.
> >> >>
> >> >> Thanks,
> >> >> Alex
> >> >>
> >> >>
> >> >> <s:subForm id = "locationSubForm">
> >> >> <h:panelGroup id="locationGroup">
> >> >>                  <h:panelGrid columns="2" style="margin-top:10px;"
> >> id="locationGrid"
> >> >> border="0" cellpadding="2">
> >> >>
> >> >>                                                    <h:outputText
> >> value="Address Name:" />
> >> >>                                                    <h:inputText
> >> id="addressName" value="#{locationForm.addressName}"
> >> >> required="true"/>
> >> >>
> >> >>                                                    <h:message
> >> for="addressName" />
> >> >>                                                    <h:outputText
> >> value="" />
> >> >>
> >> >>                                                    <h:outputText
> >> value="Street Address:" />
> >> >>                                                    <h:inputText
> >> id="streetAddress" value="#{locationForm.streetAddress}"
> >> >> />
> >> >>
> >> >>                                                    <h:outputText
> >> value="City:" />
> >> >>                                                    <h:inputText
> >> id="city" value="#{locationForm.city}" />
> >> >>
> >> >>                                                    <h:outputText
> >> value="State:" />
> >> >>
> >> >>                                                    <h:selectOneMenu
> >> value="#{locationForm.state}"
> >> >> style="padding:0px;margin:0px;">
> >> >>
> >> <a4j:support event="onchange" action="#{locationForm.loadState}"
> >> >> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/>
> >> >>
> >> <f:selectItems value ="#{locationForm.stateList}" />
> >>
> >>                                                    </h:selectOneMenu>
> >> >>
> >> >>                                                    ...
> >> >>
> >> >>                                                    <t:commandButton
> >> action="#{locationForm.submitNewLocation}"
> >> >> value="Submit" actionFor="locationSubForm"/>
> >> >>                                                    <h:outputText
> >> value="" escape="false"/>
> >> >>                                   </h:panelGrid>
> >> >>                  </h:panelGroup>
> >> >> </s:subForm>
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9397483
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by raindogs <co...@yahoo.com>.
Thanks for the response. I did put the <a4j:outputPanel ajaxRendered="true">
around the h:message tags, but the problem persists. I also tried adding the
t:saveState to the values in the drop-down, but that didn't work either.

I also posted this to the Ajax4Jsf forum on the JBoss site, but anyone here
who can think of another way around this will immediately earn a spot on my
Christmas card list.




Adrian Mitev-2 wrote:
> 
> The h:message/h:messages component is not rendering anything if there is
> no
> error message and that's why it cannot be rerendered if there is an error
> message (this is the most possible reason for your action method not to be
> invoked).
> Nest the h:message tag into <a4j:outputPanel ajaxRendered="true"> like
> this:
> 
> <a4j:outputPanel ajaxRendered="true">
>   <h:message for="addressName" />
> </a4j:outputPanel>
> 
> 
> 2007/3/8, Siju.Varghese@equifax.com <Si...@equifax.com>:
>>
>>
>> I too had this problem, in my case the managed bean was in request scope.
>> I did a t:saveState on the select item list and it solved the problem.
>>
>> -Siju
>>
>>
>>
>>  *Jeff Bischoff <jb...@klkurz.com>*
>>
>> 03/08/2007 03:33 PM  Please respond to
>> "MyFaces Discussion" <us...@myfaces.apache.org>
>>
>>   To
>> MyFaces Discussion <us...@myfaces.apache.org>  cc
>>
>>  Subject
>> Re: [Solved] ajax4jsf trouble after a form has failed JSF validation
>>
>>
>>
>>
>>
>>
>> Raindog,
>>
>> I would ask in the new ajax4jsf forum. See [1].
>>
>> [1] http://jboss.com/index.html?module=bb&op=viewforum&f=259
>>
>> raindogs wrote:
>> > One other thing... it occurred to me that I could probably bypass any
>> > complications from JSF validation by adding immediate="true" to the
>> > "a4j:support" tag. The method did fire when I did this, but the
>> elements
>> > defined in "rerender" did not refresh. I'm sure the solution is in here
>> > somewhere, but I'm just not seeing it.
>> >
>> >
>> >
>> > raindogs wrote:
>> >> I'm having a problem getting ajax4jsf to play nice with jsf form
>> >> validation. The page below uses ajax4jsf to run a method from the bean
>> >> when the value in the "state" list changes and update a couple of
>> fields.
>> >> This works great under most circumstances. However, if the user
>> submits
>> >> the form *without* filling in the required "addressName" field, the
>> form
>> >> does not submit and the error message is displayed. This is as it
>> should
>> >> be. The trouble comes when, if the form has been submitted and is
>> >> displaying the error message for the "addressName" field, the user
>> changes
>> >> the "state" field, which should still fire off the "loadState" method.
>> In
>> >> this case, the "loadState" method never fires and none of the fields
>> in
>> >> the "reRender" list are refreshed, even if there is now a value in the
>> >> "addressname" field. The snippet below should show all of the relvant
>> >> code, any help would be much appreciated.
>> >>
>> >> Thanks,
>> >> Alex
>> >>
>> >>
>> >> <s:subForm id = "locationSubForm">
>> >> <h:panelGroup id="locationGroup">
>> >>                  <h:panelGrid columns="2" style="margin-top:10px;"
>> id="locationGrid"
>> >> border="0" cellpadding="2">
>> >>
>> >>                                                    <h:outputText
>> value="Address Name:" />
>> >>                                                    <h:inputText
>> id="addressName" value="#{locationForm.addressName}"
>> >> required="true"/>
>> >>
>> >>                                                    <h:message
>> for="addressName" />
>> >>                                                    <h:outputText
>> value="" />
>> >>
>> >>                                                    <h:outputText
>> value="Street Address:" />
>> >>                                                    <h:inputText
>> id="streetAddress" value="#{locationForm.streetAddress}"
>> >> />
>> >>
>> >>                                                    <h:outputText
>> value="City:" />
>> >>                                                    <h:inputText
>> id="city" value="#{locationForm.city}" />
>> >>
>> >>                                                    <h:outputText
>> value="State:" />
>> >>
>> >>                                                    <h:selectOneMenu
>> value="#{locationForm.state}"
>> >> style="padding:0px;margin:0px;">
>> >>
>> <a4j:support event="onchange" action="#{locationForm.loadState}"
>> >> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/>
>> >>
>> <f:selectItems value ="#{locationForm.stateList}" />
>> >>                                                    </h:selectOneMenu>
>> >>
>> >>                                                    ...
>> >>
>> >>                                                    <t:commandButton
>> action="#{locationForm.submitNewLocation}"
>> >> value="Submit" actionFor="locationSubForm"/>
>> >>                                                    <h:outputText
>> value="&nbsp;" escape="false"/>
>> >>                                   </h:panelGrid>
>> >>                  </h:panelGroup>
>> >> </s:subForm>
>> >>
>> >>
>> >>
>> >
>>
>>
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ajax4jsf-trouble-after-a-form-has-failed-JSF-validation-tf3369160.html#a9397483
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by Adrian Mitev <ad...@googlemail.com>.
The h:message/h:messages component is not rendering anything if there is no
error message and that's why it cannot be rerendered if there is an error
message (this is the most possible reason for your action method not to be
invoked).
Nest the h:message tag into <a4j:outputPanel ajaxRendered="true"> like this:

<a4j:outputPanel ajaxRendered="true">
  <h:message for="addressName" />
</a4j:outputPanel>


2007/3/8, Siju.Varghese@equifax.com <Si...@equifax.com>:
>
>
> I too had this problem, in my case the managed bean was in request scope.
> I did a t:saveState on the select item list and it solved the problem.
>
> -Siju
>
>
>
>  *Jeff Bischoff <jb...@klkurz.com>*
>
> 03/08/2007 03:33 PM  Please respond to
> "MyFaces Discussion" <us...@myfaces.apache.org>
>
>   To
> MyFaces Discussion <us...@myfaces.apache.org>  cc
>
>  Subject
> Re: [Solved] ajax4jsf trouble after a form has failed JSF validation
>
>
>
>
>
>
> Raindog,
>
> I would ask in the new ajax4jsf forum. See [1].
>
> [1] http://jboss.com/index.html?module=bb&op=viewforum&f=259
>
> raindogs wrote:
> > One other thing... it occurred to me that I could probably bypass any
> > complications from JSF validation by adding immediate="true" to the
> > "a4j:support" tag. The method did fire when I did this, but the elements
> > defined in "rerender" did not refresh. I'm sure the solution is in here
> > somewhere, but I'm just not seeing it.
> >
> >
> >
> > raindogs wrote:
> >> I'm having a problem getting ajax4jsf to play nice with jsf form
> >> validation. The page below uses ajax4jsf to run a method from the bean
> >> when the value in the "state" list changes and update a couple of
> fields.
> >> This works great under most circumstances. However, if the user submits
> >> the form *without* filling in the required "addressName" field, the
> form
> >> does not submit and the error message is displayed. This is as it
> should
> >> be. The trouble comes when, if the form has been submitted and is
> >> displaying the error message for the "addressName" field, the user
> changes
> >> the "state" field, which should still fire off the "loadState" method.
> In
> >> this case, the "loadState" method never fires and none of the fields in
> >> the "reRender" list are refreshed, even if there is now a value in the
> >> "addressname" field. The snippet below should show all of the relvant
> >> code, any help would be much appreciated.
> >>
> >> Thanks,
> >> Alex
> >>
> >>
> >> <s:subForm id = "locationSubForm">
> >> <h:panelGroup id="locationGroup">
> >>                  <h:panelGrid columns="2" style="margin-top:10px;"
> id="locationGrid"
> >> border="0" cellpadding="2">
> >>
> >>                                                    <h:outputText
> value="Address Name:" />
> >>                                                    <h:inputText
> id="addressName" value="#{locationForm.addressName}"
> >> required="true"/>
> >>
> >>                                                    <h:message
> for="addressName" />
> >>                                                    <h:outputText
> value="" />
> >>
> >>                                                    <h:outputText
> value="Street Address:" />
> >>                                                    <h:inputText
> id="streetAddress" value="#{locationForm.streetAddress}"
> >> />
> >>
> >>                                                    <h:outputText
> value="City:" />
> >>                                                    <h:inputText
> id="city" value="#{locationForm.city}" />
> >>
> >>                                                    <h:outputText
> value="State:" />
> >>
> >>                                                    <h:selectOneMenu
> value="#{locationForm.state}"
> >> style="padding:0px;margin:0px;">
> >>
> <a4j:support event="onchange" action="#{locationForm.loadState}"
> >> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/>
> >>
> <f:selectItems value ="#{locationForm.stateList}" />
> >>                                                    </h:selectOneMenu>
> >>
> >>                                                    ...
> >>
> >>                                                    <t:commandButton
> action="#{locationForm.submitNewLocation}"
> >> value="Submit" actionFor="locationSubForm"/>
> >>                                                    <h:outputText
> value="&nbsp;" escape="false"/>
> >>                                   </h:panelGrid>
> >>                  </h:panelGroup>
> >> </s:subForm>
> >>
> >>
> >>
> >
>
>
>
>

Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by Si...@equifax.com.
I too had this problem, in my case the managed bean was in request scope. 
I did a t:saveState on the select item list and it solved the problem.

-Siju




Jeff Bischoff <jb...@klkurz.com> 
03/08/2007 03:33 PM
Please respond to
"MyFaces Discussion" <us...@myfaces.apache.org>


To
MyFaces Discussion <us...@myfaces.apache.org>
cc

Subject
Re: [Solved] ajax4jsf trouble after a form has failed JSF validation






Raindog,

I would ask in the new ajax4jsf forum. See [1].

[1] http://jboss.com/index.html?module=bb&op=viewforum&f=259

raindogs wrote:
> One other thing... it occurred to me that I could probably bypass any
> complications from JSF validation by adding immediate="true" to the
> "a4j:support" tag. The method did fire when I did this, but the elements
> defined in "rerender" did not refresh. I'm sure the solution is in here
> somewhere, but I'm just not seeing it.
> 
> 
> 
> raindogs wrote:
>> I'm having a problem getting ajax4jsf to play nice with jsf form
>> validation. The page below uses ajax4jsf to run a method from the bean
>> when the value in the "state" list changes and update a couple of 
fields.
>> This works great under most circumstances. However, if the user submits
>> the form *without* filling in the required "addressName" field, the 
form
>> does not submit and the error message is displayed. This is as it 
should
>> be. The trouble comes when, if the form has been submitted and is
>> displaying the error message for the "addressName" field, the user 
changes
>> the "state" field, which should still fire off the "loadState" method. 
In
>> this case, the "loadState" method never fires and none of the fields in
>> the "reRender" list are refreshed, even if there is now a value in the
>> "addressname" field. The snippet below should show all of the relvant
>> code, any help would be much appreciated.
>>
>> Thanks,
>> Alex
>>
>>
>> <s:subForm id = "locationSubForm">
>> <h:panelGroup id="locationGroup">
>>               <h:panelGrid columns="2" style="margin-top:10px;" 
id="locationGrid"
>> border="0" cellpadding="2">
>>
>>                                               <h:outputText 
value="Address Name:" />
>>                                               <h:inputText 
id="addressName" value="#{locationForm.addressName}" 
>> required="true"/>
>> 
>>                                               <h:message 
for="addressName" />
>>                                               <h:outputText value="" />
>> 
>>                                               <h:outputText 
value="Street Address:" /> 
>>                                               <h:inputText 
id="streetAddress" value="#{locationForm.streetAddress}"
>> />
>> 
>>                                               <h:outputText 
value="City:" /> 
>>                                               <h:inputText id="city" 
value="#{locationForm.city}" />
>> 
>>                                               <h:outputText 
value="State:" /> 
>>
>>                                               <h:selectOneMenu 
value="#{locationForm.state}"
>> style="padding:0px;margin:0px;">
>> <a4j:support event="onchange" action="#{locationForm.loadState}"
>> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/> 
>> <f:selectItems value ="#{locationForm.stateList}" />
>>                                               </h:selectOneMenu>
>>
>>                                               ...
>>
>>                                               <t:commandButton 
action="#{locationForm.submitNewLocation}"
>> value="Submit" actionFor="locationSubForm"/>
>>                                               <h:outputText 
value="&nbsp;" escape="false"/>
>>                               </h:panelGrid>
>>               </h:panelGroup>
>> </s:subForm>
>> 
>> 
>>
> 




Re: [Solved] ajax4jsf trouble after a form has failed JSF validation

Posted by Jeff Bischoff <jb...@klkurz.com>.
Raindog,

I would ask in the new ajax4jsf forum. See [1].

[1] http://jboss.com/index.html?module=bb&op=viewforum&f=259

raindogs wrote:
> One other thing... it occurred to me that I could probably bypass any
> complications from JSF validation by adding immediate="true" to the
> "a4j:support" tag. The method did fire when I did this, but the elements
> defined in "rerender" did not refresh. I'm sure the solution is in here
> somewhere, but I'm just not seeing it.
> 
> 
> 
> raindogs wrote:
>> I'm having a problem getting ajax4jsf to play nice with jsf form
>> validation. The page below uses ajax4jsf to run a method from the bean
>> when the value in the "state" list changes and update a couple of fields.
>> This works great under most circumstances. However, if the user submits
>> the form *without* filling in the required "addressName" field, the form
>> does not submit and the error message is displayed. This is as it should
>> be. The trouble comes when, if the form has been submitted and is
>> displaying the error message for the "addressName" field, the user changes
>> the "state" field, which should still fire off the "loadState" method. In
>> this case, the "loadState" method never fires and none of the fields in
>> the "reRender" list are refreshed, even if there is now a value in the
>> "addressname" field. The snippet below should show all of the relvant
>> code, any help would be much appreciated.
>>
>> Thanks,
>> Alex
>>
>>
>> <s:subForm id = "locationSubForm">
>> <h:panelGroup id="locationGroup">
>> 	<h:panelGrid columns="2" style="margin-top:10px;" id="locationGrid"
>> border="0" cellpadding="2">
>>
>> 			<h:outputText value="Address Name:" />
>> 			<h:inputText id="addressName" value="#{locationForm.addressName}" 
>> required="true"/>
>> 			
>> 			<h:message for="addressName" />
>> 			<h:outputText value="" />
>> 			 	
>> 			<h:outputText value="Street Address:" /> 
>> 			<h:inputText id="streetAddress" value="#{locationForm.streetAddress}"
>> />
>> 			 	
>> 			<h:outputText value="City:" /> 
>> 			<h:inputText id="city" value="#{locationForm.city}" />
>> 			 	
>> 			<h:outputText value="State:" /> 
>>
>> 			<h:selectOneMenu value="#{locationForm.state}"
>> style="padding:0px;margin:0px;">
>> 				<a4j:support event="onchange" action="#{locationForm.loadState}"
>> reRender="latitude, longitude, city, zipcode" ajaxSingle="true"/> 
>> 				<f:selectItems value ="#{locationForm.stateList}" />
>> 			</h:selectOneMenu>
>>
>> 			...
>>
>> 			<t:commandButton action="#{locationForm.submitNewLocation}"
>> value="Submit" actionFor="locationSubForm"/>
>> 			<h:outputText value="&nbsp;" escape="false"/>
>> 		</h:panelGrid>
>> 	</h:panelGroup>
>> </s:subForm>
>> 	
>> 	
>>
>