This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSF and the fly likes Setting hidden field attributes through custom viewhandler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Setting hidden field attributes through custom viewhandler" Watch "Setting hidden field attributes through custom viewhandler" New topic
Author

Setting hidden field attributes through custom viewhandler

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
We add a hidden field to the view through a custom Viewhandler.

public UIViewRoot createView(FacesContext context, String viewName) {
Application application=context.getApplication();
UIViewRoot viewRoot = baseViewHandler.createView(context, viewName);
UIComponent component = application.createComponent(HtmlInputHidden.COMPONENT_TYPE);
if (component == null) {
String msg = "No component class registered for 'type' " ;
throw new IllegalArgumentException(msg);
}
HtmlInputHidden hidden=(HtmlInputHidden)component;
hidden.setId("eventlist");
hidden.setValue("WWF");

viewRoot.getChildren().add(component);

return viewRoot;
}

Although fields gets displayed in the html;but it does not pick up the set attributes.
The resulting HTML is thus:
<input type="hidden" name="_id0" value="_id0" />

Why are the id and value attributes not getting picked up?
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Setting hidden field attributes through custom viewhandler
 
It's not a secret anymore!