This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Dynamically created component id changed during render response phase Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Dynamically created component id changed during render response phase" Watch "Dynamically created component id changed during render response phase" New topic
Author

Dynamically created component id changed during render response phase

Mark Rausch
Greenhorn

Joined: Apr 10, 2003
Posts: 4
Hello all,

I am using myfaces 1.1.1

I have a UIInput bound to a backing bean as follows:

<h:inputText binding="#{MyBean.input}"

In MyBean I have the following:

public UIComponent getInput()
{
if (null == input)
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
input = (UIInput) app.createComponent UIInput.COMPONENT_TYPE);
input.setId("someid");
}

return input;
}

public void setInput(UIComponent input)
{
this.input = (UIInput)input;
}

During the render repsonse phase, the component id which was specified after creation using component.setId("someid") is replaced with a new id which looks something like "_id1". This was determined by implementing MyBean as a phaseListener and visually inspecting the UIViewRoot in beforePhase and afterPhase. Because the id is replaced any dynamically created Messages that may be bound to the input via the Message for attribute are now broken.

I am aware of the restrictions on setId() and am adhering to them
Must not be a zero-length String
First character must be a letter or an underscore ('_').
Subsequent characters must be a letter, a digit, an underscore ('_'), or a dash ('-').
The specified identifier must be unique

Any suggestions would be greatly appreciated.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Dynamically created component id changed during render response phase
 
Similar Threads
How do javascript refer to Jsf input field ID
Render Response phase question
Bound PanelGrid removing dynamically added components
JSF clear fields on validation errors
JSF partial validation