File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Custom message tag quite like (or utilizing) t:message Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Custom message tag quite like (or utilizing) t:message" Watch "Custom message tag quite like (or utilizing) t:message" New topic
Author

Custom message tag quite like (or utilizing) t:message

Thorsten Duhn
Greenhorn

Joined: Aug 09, 2006
Posts: 7
Hello,

I need something quite simple, I want my custom tag (called "messageIcon") to define my own way of showing the error message for an input component, a graphical icon with TITLE and JavaScript popup showing the message. In addition it needs to have at least one feature of the Tomahawk message compponent, the great "replaceIdWithLabel" feature.

What is the best way to code such. There is one major problem I can't solve. And looking at the Tomahawk implementation is really confusing, they have at least twelve files for the (Html)Message while I think three should be enought to create a custom tag (in my case: MessageIconTag, UIMessageIcon, MessageIconRenderer).

I do have a working prototype, but this deals with a major problem, so I think my whole concept is wrong. The problem is how to address the related components, the input and the label. They are all linked by the id-attribute of the input and the for-attributes of label and message(Icon). But what I have when rendering the message is the pure id from the for-attribute and the jsf generated clientIds of getClientIdsWithMessages(). What is the way to get the belonging input component. It can't be based on literal matching (as I do now). Especially within a list the ids defined in jsp code are not unique (the JSF generated clientIds are, but how to match them?).

A stupid little idea I have (to work around all this internals) is to actually use a Tomahawk HtmlMessage (in UIMessageIcon) and with a bit heavy magic get its values (the current error message, including resolved label) without rendering it (in MessageIconRenderer), to use this values on my own to render components (HtmlOutputLink and HtmlGraphicImage). Is this possible?

On the other hand for another component I need to get the related input component as well (to get it's required value to display an required mark - or not). So a way to solve this would really be great.

Or just some hints to find my way through the Tomahawk code...

Regards,
Thorsten
[ August 25, 2006: Message edited by: Thorsten Duhn ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

"Thorsten",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Thorsten Duhn
Greenhorn

Joined: Aug 09, 2006
Posts: 7
Hello,

okay, I've done the trick myself. Just using findComponent() does it, it's obviously clever enough to be aware of it's context, in lists for example. And for my needed "replaceIdWithLabel" feature the solution is in org.apache.myfaces.renderkit.html.ext.HtmlMessageRenderer.getOutputLabelMap().

Regards,
Thorsten
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Custom message tag quite like (or utilizing) t:message
 
Similar Threads
Associating an icon with h:message
SelectItem and labels
How to create JSF custom tag
tomahawk not working with SUN JSF RI
getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP!