The code is pretty simplistic for the component:

@FaceletComponent(namespace = "http://christws.com/components";,
  tagName = "helpIcon",
  type = UIHelpIcon.COMPONENT_TYPE,
  rendererType = HelpIconRenderer.RENDERER_TYPE)
public class UIHelpIcon
  extends CoreCommandLink
{
  public final static String COMPONENT_FAMILY = "com.christws.HelpIcon";
  public final static String COMPONENT_TYPE = "com.christws.HelpIcon";

  public final static FacesBean.Type TYPE = new FacesBean.Type(
    CoreCommandLink.TYPE);
  public final static PropertyKey MESSAGE_ID_KEY =
    TYPE.registerKey("messageId", String.class);
  public final static PropertyKey FOR_KEY =
    TYPE.registerKey("for", String.class);

  static
  {
    TYPE.lockAndRegister(COMPONENT_FAMILY, COMPONENT_TYPE);
  };

  public UIHelpIcon()
  {
    super(HelpIconRenderer.RENDERER_TYPE);
  }

  /**
   * @see 
org.apache.myfaces.trinidad.component.UIXComponentBase#getClientId(javax.faces.context.FacesContext)
   */
  @Override
  public String getClientId(FacesContext context)
  {
    // TODO Auto-generated method stub
    String id = super.getClientId(context);
    return id;
  }

  /**
   * @see javax.faces.component.UIComponent#getFamily()
   */
  @Override
  public String getFamily()
  {
    return COMPONENT_FAMILY;
  }

  public String getMessageId()
  {
    return ComponentUtils.resolveString(getProperty(MESSAGE_ID_KEY));
  }

  public void setMessageId(String messageId)
  {
    setProperty(MESSAGE_ID_KEY, messageId);
  }

  public String getFor()
  {
    return ComponentUtils.resolveString(getProperty(FOR_KEY));
  }

  public void setFor(String value)
  {
    setProperty(FOR_KEY, value);
  }

  /**
   * @see org.apache.myfaces.trinidad.component.UIXComponentBase#getBeanType()
   */
  @Override
  protected Type getBeanType()
  {
    return TYPE;
  }

  /**
   * @see 
org.apache.myfaces.trinidad.component.UIXCommand#broadcast(javax.faces.event.FacesEvent)
   */
  @Override
  public void broadcast(FacesEvent event) throws AbortProcessingException
  {
    if (event instanceof ActionEvent)
    {
      HelpBean bean = FacesUtils.getBean(HelpBean.class, true);
      bean.setCurrentHelpTopicKey(getMessageId());
    }
    super.broadcast(event);
  }
}

As you can see, I haven't done anything to the state saving at all. I
haven't setup the maven component generation in my project yet so the
above component was hand-written, but I don't think I made any
mistakes, but not positive.

On 9/5/07, Adam Winer <[EMAIL PROTECTED]> wrote:
> I don't see how or why this is wrong...  _genId should get state
> saved, so I don't understand why you're having problems unless
> your custom component has overridden state saving incorrectly.
> I've never seen a problem like this with any of our Trinidad components.
>
> -- Adam
>
>
> On 9/5/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> > I am wondering if this is a bug or planned with UIXComponentBase:
> >
> > I was noticing that my custom component that extended CoreCommandLink
> > stopped working after a partial update. When trying to figure out why,
> > I noticed that the ID of the link changed between rendering and
> > therefore the decode no longer worked.
> >
> > On first page rendering, the link ID was _id44. During decode, it was
> > still _id44. During encode, it was _id108. It failed partial update
> > because the ID changed, and therefore all further decodes failed since
> > the client was now out of sync from the server.
> >
> > In UIComponentBase.getClientId, if the getId() returns null, a new ID
> > is created and then setId is called. UIXComponentBase never calls
> > setId, but instead caches it in a "_genId" property using the
> > FacesBean.
> >
> > Therefore, anything extending UIComponentBase and has a generated ID
> > will never have its ID change between requests on the same view.
> > However, it seems that UIXComponentBase does not guarantee that a
> > component with a generated ID will have a consistent ID.
> >
> > Here is my code:
> >
> > <tr:panelLabelAndMessage
> >   label="Test help">
> >   <tr:inputText id="testHelp" value="#{testHelpText}"
> >     simple="true" />
> >   <f:facet name="end">
> >     <cw:helpIcon for="testHelp"
> >       messageId="test_help" />
> >   </f:facet>
> > </tr:panelLabelAndMessage>
> >
> > The cw:helpIcon extends CoreCommandLink
> >
> > If I give the helpIcon a hard coded ID, it works fine.
> >
> > Is this a bug, a shortcoming, or just not supported with UIXComponentBase?
> >
> > I seems like it could be a very big source of problems if IDs change
> > between requests, as decodes will have a lot of problems. Should
> > UIXComponentBase be calling setId after generating an ID in the
> > getClientId function?
> >
> > This was found on 1.0.3-SNAPSHOT
> >
> > Any ideas?
> >
> > Thanks,
> > Andrew
> >
>
>

Reply via email to