You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by daniel ccss <da...@gmail.com> on 2008/03/13 19:05:58 UTC

Ajax + Inmediate="true" Problem

Hi all,

I´m using JSF Tomahawk and ajax, but something happens.

I have a <t:inputText that is where the user enters the ID of a person and
next to that input I have a <t:commanLink for search the info of the person
after the id is typed. Also in that same form, i have some <h:selectOneMenu
controls that uses ajax to fill one from other, for example if the value of
the <h:selectOneMenu1 changes it changes the values of the <h:selectOneMenu2
using Ajax:

<a4j:support event="onchange" action="#{PatientBean.updateCountry}"
reRender="*cities*" /> ....

This is the problem, for some reason if I typed the id of the user and click
on the <t:commandLink nothing happens, then I put an <h:messages to see what
was going on and I recived a message that says that the *cities *variable
was null so the action was never called....

Then I select the values of the <h:selectOneMenu1 and then select the value
<h:selectOneMenu2 and then I enter the ID int the input and click the
<t:commanLink and the action of the backing bean was called sucesfully, but
because the cities variable was not null...

Then to try to resolve the problem I put an inmediate="true" attribute in
the <t:commanLink. Then I enter ther person ID and then I click
<t:commanLink  and it calls the method of the backing bean, but the ID comes
empty...

What is going on?? Why I have to fill the <h:selectOneMenus first to then
call the action, I not use a requiered attribute for them?? Why the
inmediate="true" works but the <t:inputText is null?? All works if I first
fill the <h:selectOneMenu that uses ajax and are in an ajax:region and then
call the action method, but don´t need that, I can first search the id if I
want and then fill the <h:selectOneMenus.

Do anyone knows why this happen and which is the solution?  Thanks!!

Regards,

Re: Ajax + Inmediate="true" Problem

Posted by Martin Marinschek <ma...@gmail.com>.
Hi Daniel,

putting immediate=true to your input component will not be sufficient.
The problem is that immediate=true will trigger the validation for
your input-component, but nothing more than that. So what happens is
your value is converted and validated, but not put into your managed
bean. What you will need to do is register a value-change-listener for
the comp, and then move over the value to your backing-bean yourself.

regards,

Martin

On Fri, Mar 14, 2008 at 12:02 AM, Andrew Robinson
<an...@gmail.com> wrote:
> Have a look at <a4j:region> it may be what you are looking for
>
>
>
>  On Thu, Mar 13, 2008 at 3:14 PM, daniel ccss <da...@gmail.com> wrote:
>  > I attach a graphical image of what is happening
>



-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Ajax + Inmediate="true" Problem

Posted by Andrew Robinson <an...@gmail.com>.
Have a look at <a4j:region> it may be what you are looking for

On Thu, Mar 13, 2008 at 3:14 PM, daniel ccss <da...@gmail.com> wrote:
> I attach a graphical image of what is happening

Re: Ajax + Inmediate="true" Problem

Posted by daniel ccss <da...@gmail.com>.
I attach a graphical image of what is happening

Re: Ajax + Inmediate="true" Problem

Posted by daniel ccss <da...@gmail.com>.
My question is the same that this person did here:

http://www.nabble.com/action-only-called-when-immediate%3Dtrue-td7778196.html

The only differences is that my <h:selectOneMenu are not required.

Thanks



On Thu, Mar 13, 2008 at 12:58 PM, daniel ccss <da...@gmail.com> wrote:

> Thanks, I did what you said and nothing, the inputText comes in null.
>
> Let me explain better my problem, the problem is that to call the action
> by the command link, first i need to fill the selectOneMenu combos that are
> updated by ajax, if I don´t do that, I recived an h:message that says that
> the variable of the selectOneMenu is null and the action is never called
>
>
>
> On Thu, Mar 13, 2008 at 12:32 PM, Mike Kienenberger <mk...@gmail.com>
> wrote:
>
> > I'm not following everything you're saying, but if you make
> > commandLink immediate=true, then you need to make inputText
> > immediate=true if you want to have access to that data from your
> > commandLink's action.
> >
> > On 3/13/08, daniel ccss <da...@gmail.com> wrote:
> > > Hi all,
> > >
> > > I´m using JSF Tomahawk and ajax, but something happens.
> > >
> > > I have a <t:inputText that is where the user enters the ID of a person
> > and
> > > next to that input I have a <t:commanLink for search the info of the
> > person
> > > after the id is typed. Also in that same form, i have some
> > <h:selectOneMenu
> > > controls that uses ajax to fill one from other, for example if the
> > value of
> > > the <h:selectOneMenu1 changes it changes the values of the
> > <h:selectOneMenu2
> > > using Ajax:
> > >
> > > <a4j:support event="onchange" action="#{PatientBean.updateCountry}"
> > > reRender="cities" /> ....
> > >
> > > This is the problem, for some reason if I typed the id of the user and
> > click
> > > on the <t:commandLink nothing happens, then I put an <h:messages to
> > see what
> > > was going on and I recived a message that says that the cities
> > variable was
> > > null so the action was never called....
> > >
> > > Then I select the values of the <h:selectOneMenu1 and then select the
> > value
> > > <h:selectOneMenu2 and then I enter the ID int the input and click the
> > > <t:commanLink and the action of the backing bean was called
> > sucesfully, but
> > > because the cities variable was not null...
> > >
> > > Then to try to resolve the problem I put an inmediate="true" attribute
> > in
> > > the <t:commanLink. Then I enter ther person ID and then I click
> > > <t:commanLink  and it calls the method of the backing bean, but the ID
> > comes
> > > empty...
> > >
> > > What is going on?? Why I have to fill the <h:selectOneMenus first to
> > then
> > > call the action, I not use a requiered attribute for them?? Why the
> > > inmediate="true" works but the <t:inputText is null?? All works if I
> > first
> > > fill the <h:selectOneMenu that uses ajax and are in an ajax:region and
> > then
> > > call the action method, but don´t need that, I can first search the id
> > if I
> > > want and then fill the <h:selectOneMenus.
> > >
> > > Do anyone knows why this happen and which is the solution?  Thanks!!
> > >
> > > Regards,
> > >
> >
>
>

Re: Ajax + Inmediate="true" Problem

Posted by daniel ccss <da...@gmail.com>.
Thanks, I did what you said and nothing, the inputText comes in null.

Let me explain better my problem, the problem is that to call the action by
the command link, first i need to fill the selectOneMenu combos that are
updated by ajax, if I don´t do that, I recived an h:message that says that
the variable of the selectOneMenu is null and the action is never called


On Thu, Mar 13, 2008 at 12:32 PM, Mike Kienenberger <mk...@gmail.com>
wrote:

> I'm not following everything you're saying, but if you make
> commandLink immediate=true, then you need to make inputText
> immediate=true if you want to have access to that data from your
> commandLink's action.
>
> On 3/13/08, daniel ccss <da...@gmail.com> wrote:
> > Hi all,
> >
> > I´m using JSF Tomahawk and ajax, but something happens.
> >
> > I have a <t:inputText that is where the user enters the ID of a person
> and
> > next to that input I have a <t:commanLink for search the info of the
> person
> > after the id is typed. Also in that same form, i have some
> <h:selectOneMenu
> > controls that uses ajax to fill one from other, for example if the value
> of
> > the <h:selectOneMenu1 changes it changes the values of the
> <h:selectOneMenu2
> > using Ajax:
> >
> > <a4j:support event="onchange" action="#{PatientBean.updateCountry}"
> > reRender="cities" /> ....
> >
> > This is the problem, for some reason if I typed the id of the user and
> click
> > on the <t:commandLink nothing happens, then I put an <h:messages to see
> what
> > was going on and I recived a message that says that the cities variable
> was
> > null so the action was never called....
> >
> > Then I select the values of the <h:selectOneMenu1 and then select the
> value
> > <h:selectOneMenu2 and then I enter the ID int the input and click the
> > <t:commanLink and the action of the backing bean was called sucesfully,
> but
> > because the cities variable was not null...
> >
> > Then to try to resolve the problem I put an inmediate="true" attribute
> in
> > the <t:commanLink. Then I enter ther person ID and then I click
> > <t:commanLink  and it calls the method of the backing bean, but the ID
> comes
> > empty...
> >
> > What is going on?? Why I have to fill the <h:selectOneMenus first to
> then
> > call the action, I not use a requiered attribute for them?? Why the
> > inmediate="true" works but the <t:inputText is null?? All works if I
> first
> > fill the <h:selectOneMenu that uses ajax and are in an ajax:region and
> then
> > call the action method, but don´t need that, I can first search the id
> if I
> > want and then fill the <h:selectOneMenus.
> >
> > Do anyone knows why this happen and which is the solution?  Thanks!!
> >
> > Regards,
> >
>

Re: Ajax + Inmediate="true" Problem

Posted by Mike Kienenberger <mk...@gmail.com>.
I'm not following everything you're saying, but if you make
commandLink immediate=true, then you need to make inputText
immediate=true if you want to have access to that data from your
commandLink's action.

On 3/13/08, daniel ccss <da...@gmail.com> wrote:
> Hi all,
>
> I´m using JSF Tomahawk and ajax, but something happens.
>
> I have a <t:inputText that is where the user enters the ID of a person and
> next to that input I have a <t:commanLink for search the info of the person
> after the id is typed. Also in that same form, i have some <h:selectOneMenu
> controls that uses ajax to fill one from other, for example if the value of
> the <h:selectOneMenu1 changes it changes the values of the <h:selectOneMenu2
> using Ajax:
>
> <a4j:support event="onchange" action="#{PatientBean.updateCountry}"
> reRender="cities" /> ....
>
> This is the problem, for some reason if I typed the id of the user and click
> on the <t:commandLink nothing happens, then I put an <h:messages to see what
> was going on and I recived a message that says that the cities variable was
> null so the action was never called....
>
> Then I select the values of the <h:selectOneMenu1 and then select the value
> <h:selectOneMenu2 and then I enter the ID int the input and click the
> <t:commanLink and the action of the backing bean was called sucesfully, but
> because the cities variable was not null...
>
> Then to try to resolve the problem I put an inmediate="true" attribute in
> the <t:commanLink. Then I enter ther person ID and then I click
> <t:commanLink  and it calls the method of the backing bean, but the ID comes
> empty...
>
> What is going on?? Why I have to fill the <h:selectOneMenus first to then
> call the action, I not use a requiered attribute for them?? Why the
> inmediate="true" works but the <t:inputText is null?? All works if I first
> fill the <h:selectOneMenu that uses ajax and are in an ajax:region and then
> call the action method, but don´t need that, I can first search the id if I
> want and then fill the <h:selectOneMenus.
>
> Do anyone knows why this happen and which is the solution?  Thanks!!
>
> Regards,
>