aspose file tools*
The moose likes JSF and the fly likes Custom tag that overrides UIInput Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom tag that overrides UIInput" Watch "Custom tag that overrides UIInput" New topic
Author

Custom tag that overrides UIInput

Chris Gage
Greenhorn

Joined: Mar 23, 2005
Posts: 17

I want to create a custom version of UIInput (aka h:inputText) which will render normally as a UIInput EXCEPT when the tag has disabled="true"; in that case it will then render as an output field with an appropriate CSS style. Is this possible?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/css3-modsel-24.html


Customer surveys are for companies who didn't pay proper attention to begin with.
Chris Gage
Greenhorn

Joined: Mar 23, 2005
Posts: 17

Ahem... Er...

It was the java code for the JSF custom tag I was asking about. After all, this is a JSF forum, right?

Tags that are totally standalone and have simple attributes are easy - I have done many. But when you want to make a specific change in the behaviour of a single attribute of the existing standard h:inputText tag, it becomes far more difficult, if not impossible. See my recent posts on the IBM Developerworks JSF forum as well as the replies from the IBM folks.
Chris Gage
Greenhorn

Joined: Mar 23, 2005
Posts: 17

Oh, and another thing, that CSS example doesn't work with IE, it shows up illegible with a RED background. And that is EXACTLY why I want to change the behavior of the tag so it outputs a styled string instead of an input field when disabled="true".
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

I must say, I'm SHOCKED, absolutely SHOCKED to hear that IE isn't being standards compliant.

Ironically, I had to do another one of those just yesterday. Here's what I do:



The two "lr7PID fields count as a single column in the containing panelGrid, since only one renders at a time.

I tried the CSS stuff and I wasn't impressed either. Even in Firefox it worked only erratically, and I couldn't suppress the border when the field was readonly.
Chris Gage
Greenhorn

Joined: Mar 23, 2005
Posts: 17

We have more or less what you describe already, I was just looking to "declutter" the source of our 200-odd JSPs with a single tag that renders either one...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

If you're using Facelets, you can make up a custom facelets component that way. I just did something similar myself. No Java code required, just xml tag definitions.
Chris Gage
Greenhorn

Joined: Mar 23, 2005
Posts: 17

Agreed. I very much like Facelets, particularly the template capability. However, my customer may see it in a different way - a switch from vanilla JSF to Facelets is a whole new technology, therefore somewhat more disruptive. Custom components are less so, partly because they already have several of them, in fact the entire page/menu system for these 200 JSPs is based on a custom tag I wrote that all the JSPs use through a template, plus they make widespread use of converters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom tag that overrides UIInput