Hi All,

I've always hated the "forceId" feature of tomahawk for two reasons:
(a) it makes it dangerous to compose pages using facelets templating,
jsp:include or similar
(b) it only works for tomahawk components

There is nothing that can be done about (a); any "flattening" of the id
is dangerous. But sometimes it is just necessary.

It is possible to do something about (b) though. JSF1.2 adds method
UIComponentBase.getContainerClientId. A trivial component can therefore
be written that prevents any prefix being applied to the ids of its
child components:

<f:subview id="mysubview1">
  <h:commandButton id="btn1" ../>      # clientId = "mysubview1:btn1"

  <s:globalId id="whatever">
    <h:commandButton id="btn2" .../>   # clientId="btn2"
    <h:graphicImage id="img1" ../>        # clientId="img1"
  </s:globalId>
</f:subview>

The implementation is trivial:

public class GlobalId extends UIComponentBase implements NamingContainer
{
    private final static String COMPONENT_FAMILY = "oamc.GlobalId";

    public String getFamily()
    {
        return COMPONENT_FAMILY;
    }

    public String getContainerClientId(FacesContext facesContext)
    {
        return null;
    }
}

Note that this component would only work for JSF1.2 or later (though it
will compile fine with JSF1.1).

Would this be useful or not?

Regards,
Simon

-- 
-- Emails in "mixed" posting style will be ignored
-- (http://en.wikipedia.org/wiki/Posting_style)

Reply via email to