You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gr...@intellicare.com on 2005/10/06 17:30:51 UTC

[Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

I know I should set this problem with error messages down and move on, 
but.. it's got me intrigued.. So, since I couldn't get Craig's cool idea 
to work, I decided to probe a bit. 

Here's what I have in my RegistrationBean (backing bean):

private HtmlInputSecret password = null; (with usual getter and setter ..)

String pClientid = 
password.getClientId(FacesContext.getCurrentInstance());
System.out.println("pClientid is: " + pClientid);
>>Output: pClientid is: registrationForm:password
 
UIComponent uic = 
FacesContext.getCurrentInstance().getViewRoot().findComponent(pClientid);
System.out.println("uic: " + 
uic.getClientId(FacesContext.getCurrentInstance()));
>>Output: uic: registrationForm:password

error(uic, messages.getMessage("password.mismatch"));

Iterator itt = 
FacesContext.getCurrentInstance().getClientIdsWithMessages();
while (itt.hasNext()) {
        System.out.println("nextOne is: " + itt.next());
}
>>Output: nextOne is: null

So seems like I am in fact queuing a FacesMessage to a "good" UICompenent 
with my error(.. ) call, however, it is mysteriously not appearing within 
my iterator. (So it is no wonder that the jsp doeasn't display properly 
with my error message in the proper place..)

Does anyone see what the problem is..?

Many thanks in advance!
Geeta

[OT] Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by gr...@intellicare.com.
Ronald Holshausen <ug...@gmail.com> wrote on 10/07/2005 11:57:00 AM:

> If you get a later version of shale, you can then use the message
> functions :-) They just do what your code does anyway.
> 

so guess what i am doing *right* now..? :) 

Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by Ronald Holshausen <ug...@gmail.com>.
If you get a later version of shale, you can then use the message
functions :-) They just do what your code does anyway.

On 07/10/05, gramani@intellicare.com <gr...@intellicare.com> wrote:
> Ronald Holshausen <ug...@gmail.com> wrote on 10/07/2005 11:30:21 AM:
>
> > aah! There is a bug with the AbstractFacesBean message functions. They
> > do not set the client id when adding the messages. It was fixed in
> > nightly build 20050921, but I don't think it has been tested yet.
> >
> > I never used the methods in AbstractFacesBean, but it is easy to test.
> > You can add the messages yourself by using
> > context.addMessage(clientId, message).
>
> *Fantastic*, thanks so much, Ronald! Certainly that was the problem..
> though my solution as suggested by you is a bit ironic, since I went down
> the path of AbstractFacesBean.errors(...) mainly since I wanted to avoid
> having to get the clientId in the first place..:)
>
> So my code now is the rather ugly:
> FacesContext.getCurrentInstance().addMessage(password.getClientId(FacesContext.getCurrentInstance()),
>
>                 new
> FacesMessage(messages.getMessage("password.mismatch")));
>
> instead of the sleek:
>         errors(password, messages.getMessage("password.mismatch"));
>
> But I guess "it works" beats good looks any day, huh? ;)
>
> Thank you again!
> Geeta
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by gr...@intellicare.com.
Ronald Holshausen <ug...@gmail.com> wrote on 10/07/2005 11:30:21 AM:

> aah! There is a bug with the AbstractFacesBean message functions. They
> do not set the client id when adding the messages. It was fixed in
> nightly build 20050921, but I don't think it has been tested yet.
> 
> I never used the methods in AbstractFacesBean, but it is easy to test.
> You can add the messages yourself by using
> context.addMessage(clientId, message).

*Fantastic*, thanks so much, Ronald! Certainly that was the problem.. 
though my solution as suggested by you is a bit ironic, since I went down 
the path of AbstractFacesBean.errors(...) mainly since I wanted to avoid 
having to get the clientId in the first place..:)

So my code now is the rather ugly:
FacesContext.getCurrentInstance().addMessage(password.getClientId(FacesContext.getCurrentInstance()), 

                new 
FacesMessage(messages.getMessage("password.mismatch")));

instead of the sleek:
        errors(password, messages.getMessage("password.mismatch"));

But I guess "it works" beats good looks any day, huh? ;)

Thank you again!
Geeta

Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by Ronald Holshausen <ug...@gmail.com>.
aah! There is a bug with the AbstractFacesBean message functions. They
do not set the client id when adding the messages. It was fixed in
nightly build 20050921, but I don't think it has been tested yet.

I never used the methods in AbstractFacesBean, but it is easy to test.
You can add the messages yourself by using
context.addMessage(clientId, message).

On 07/10/05, gramani@intellicare.com <gr...@intellicare.com> wrote:
> Ronald Holshausen <ug...@gmail.com> wrote on 10/07/2005 05:03:23 AM:
>
> > Hmm, I have used the 1.1_01 and the messages definitly work. Does your
> > bean extend the abstract one from shale (AbstractFacesBean)? Or is the
> > error method one you wrote?
> >
>
> Thanks for your note Ronald. My bean extends AbstractViewController and so
> it's defintely using shale's AbstractFacesBean's error method. If this is
> working well for you it's doubtless something wrong I'm doing; though I
> really cannot figure out what since I am seemingly setting the error
> message and rightwaay checking for it using getClientIdsWithMessages (both
> in the same bean - so there's no question of config problems or issues
> with my jsp..)
>
> Hmm.. ok, can you easily throw in this code:
> Iterator itt =
> FacesContext.getCurrentInstance().getClientIdsWithMessages();
>                                 while (itt.hasNext()) {
>                                         System.out.println("nextOne is: "
> + itt.next());
>                                 }
> right after you set your error message in your bean and see if you get
> anything..? I am wondering now if there's something off with
> getClientIdsWithMessages()... in that case, there must be something wrong
> elsewhere in my code..
>
> Thank you for your time and patience!
> Geeta
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by gr...@intellicare.com.
Ronald Holshausen <ug...@gmail.com> wrote on 10/07/2005 05:03:23 AM:

> Hmm, I have used the 1.1_01 and the messages definitly work. Does your
> bean extend the abstract one from shale (AbstractFacesBean)? Or is the
> error method one you wrote?
> 

Thanks for your note Ronald. My bean extends AbstractViewController and so 
it's defintely using shale's AbstractFacesBean's error method. If this is 
working well for you it's doubtless something wrong I'm doing; though I 
really cannot figure out what since I am seemingly setting the error 
message and rightwaay checking for it using getClientIdsWithMessages (both 
in the same bean - so there's no question of config problems or issues 
with my jsp..)

Hmm.. ok, can you easily throw in this code:
Iterator itt = 
FacesContext.getCurrentInstance().getClientIdsWithMessages();
                                while (itt.hasNext()) {
                                        System.out.println("nextOne is: " 
+ itt.next());
                                }
right after you set your error message in your bean and see if you get 
anything..? I am wondering now if there's something off with 
getClientIdsWithMessages()... in that case, there must be something wrong 
elsewhere in my code..

Thank you for your time and patience!
Geeta

Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by Ronald Holshausen <ug...@gmail.com>.
Hmm, I have used the 1.1_01 and the messages definitly work. Does your
bean extend the abstract one from shale (AbstractFacesBean)? Or is the
error method one you wrote?

On 06/10/05, gramani@intellicare.com <gr...@intellicare.com> wrote:
> Ronald Holshausen <ug...@gmail.com> wrote on 10/06/2005 11:53:08 AM:
>
> > Hi Geeta,
> >
> > Which JSF implementation are you using? And are you running it in a
> > servlet or portlet enviroment?
> >
>
> Hi Ronald, I had been using Sun's implementation (version 1.1) but after I
> got your note, I downloaded their latest 1.1_01 jars and tried with those,
> but unfortunately I get the same results.
>
> And I am working in a servlet environment.
>
> Thank you for your time!
> Geeta
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by gr...@intellicare.com.
Ronald Holshausen <ug...@gmail.com> wrote on 10/06/2005 11:53:08 AM:

> Hi Geeta,
> 
> Which JSF implementation are you using? And are you running it in a
> servlet or portlet enviroment?
> 

Hi Ronald, I had been using Sun's implementation (version 1.1) but after I 
got your note, I downloaded their latest 1.1_01 jars and tried with those, 
but unfortunately I get the same results.

And I am working in a servlet environment.

Thank you for your time!
Geeta

Re: [Shale] getClientIdsWithMessages in FacesContext doesn't seem to work..?

Posted by Ronald Holshausen <ug...@gmail.com>.
Hi Geeta,

Which JSF implementation are you using? And are you running it in a
servlet or portlet enviroment?

On 06/10/05, gramani@intellicare.com <gr...@intellicare.com> wrote:
> I know I should set this problem with error messages down and move on,
> but.. it's got me intrigued.. So, since I couldn't get Craig's cool idea
> to work, I decided to probe a bit.
>
> Here's what I have in my RegistrationBean (backing bean):
>
> private HtmlInputSecret password = null; (with usual getter and setter ..)
>
> String pClientid =
> password.getClientId(FacesContext.getCurrentInstance());
> System.out.println("pClientid is: " + pClientid);
> >>Output: pClientid is: registrationForm:password
>
> UIComponent uic =
> FacesContext.getCurrentInstance().getViewRoot().findComponent(pClientid);
> System.out.println("uic: " +
> uic.getClientId(FacesContext.getCurrentInstance()));
> >>Output: uic: registrationForm:password
>
> error(uic, messages.getMessage("password.mismatch"));
>
> Iterator itt =
> FacesContext.getCurrentInstance().getClientIdsWithMessages();
> while (itt.hasNext()) {
>         System.out.println("nextOne is: " + itt.next());
> }
> >>Output: nextOne is: null
>
> So seems like I am in fact queuing a FacesMessage to a "good" UICompenent
> with my error(.. ) call, however, it is mysteriously not appearing within
> my iterator. (So it is no wonder that the jsp doeasn't display properly
> with my error message in the proper place..)
>
> Does anyone see what the problem is..?
>
> Many thanks in advance!
> Geeta
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org