must one explicitly set ID of UICommand in custom UIData?

I have a custom UIData subclass that, when created, dynamically creates its child columns just as if they had been created from a JSP.

I add a button using:

application.createComponent(UICommand.COMPONENT_TYPE);

I had understood that, if I didn't specify an ID, that JSF would generate one. However, it seems that JSF generates a new IDeach time the column is renderedthat is, for each row in the UIData!

In other words, if I have a button in a UIData column that is generated from a JSP, the generated client IDs look something like this when rendered:

_id64:_id65:0:_id67

_id64:_id65:1:_id67

_id64:_id65:2:_id67

But if I create the same UIData and UICommand dynamically using application.createComponent() and don't explicitly assign an ID, the client IDs generated are something like:

_id64:_id65:0:_id67

_id64:_id65:1:_id68

_id64:_id65:2:_id69

This stops the UICommand from working, because inside UICommand.encode() the component checks its clientID (which by this time is _id64:_id65:0:_id92 or something), which doesn't match the clientID sent back from the HTTP POST from the HTML button name attribute.

This all stems from UIComponentBase.getClientId() which, if there is no explicitly set ID for a component inside a naming container such as UIData, returns:

clientId = parentIds + context.getViewRoot().createUniqueId();

This leads me to believe that, if a component structure is created from a JSP, JSF automatically calls:

newComponent.setId(context.getViewRoot().createUniqueId());

Is this the way JSF is designed? That is, when I create a new component dynamically, am I required to set its ID, using context.getViewRoot().createUniqueId() for example?

Garret

[1800 byte] By [GarretWilson] at [2007-9-30 21:17:45]
# 1
...but why isn't the clientID cached? I see that UIComponentBase apparently caches the generated client IDany idea why it isn't being saved in this case?Garret
GarretWilson at 2007-7-7 2:50:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...