4 Replies Latest reply on Apr 14, 2011 12:00 PM by Chris Mathrusse

    Problem with invokeOnComponent

    Chris Mathrusse Newbie

      I'm usig RichFaces 4 and I'm having an issue invalidating a component and assigning a message to it. My code worked previously with RichFaces 4 M5, but now that I am using 4.0.0 final, it appears that it no longer works. It seems to be an issue with the ids of the components.

       

      Here is my Java code:

       

                                              final String resId = resourceId;

                                              final String compId = componentId;

                                              FacesContext context = FacesContext.getCurrentInstance();

                                              context.getViewRoot().invokeOnComponent(context, compId,

                                                                  new ContextCallback() {

       

                                         @Override

                                                                            public void invokeContextCallback(

                                                                                                FacesContext context, UIComponent component) {

                                                                                      ((UIInput) component).setValid(false);

       

                                                                                      FacesMessage message = new FacesMessage(

                                                                                                          MessageUtils.getString(resId));

                                                                                      context.addMessage(

                                                                                                          component.getClientId(context), message);

                                                                            }

                                                                  });

       

      The compId that I am supplying is the value of the form id and the actual component id concatinated together.

      (quote-only-form:cal-checkin-date)

       

      When the method invokeOnComponent is called, my callback is never invoked because the component Id cannot be located. I've setup a valueChangeListener on the component so I can see what the component clientId is and it has a value other than what I expected.

      (quote-only-form:j_idt57:cal-checkout-date)

       

      I don't know why the value is different than what it previously was or why there is now a j_idt57 in the clientId, but this seems to be preventing my callback from being invoked.

       

      Is there any reason why the clientId of the component would change like this or is there something that I am overlooking when calling invokeOnComponent?

       

      Thanks for the help...