• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSF - How can I get hyperlink in error messages?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a scenario in which I need to embed a hyperlink in the error message.
When I use, <h:messages> tag the error message is displayed as
NameField is required.
Here NameField is a field on the screen.
The scenario here is that the message should be dispalyed as
NameField is required.
When the user clicks on the link NameField, the user is taken to that NameField on the JSP.

I want to use this across the application so is it possible to write some custom tag and if so how?
How can it be possible to create a hyperlink within a message?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry, but I didn't understand your question. You want have a link, and when link is clicked call some jsp ?
 
Poornima Bileyali
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp....

Field 1 : <Text box>

Field 2 : <Text Box>

Say i am validating required and dont enter anything...

on submiting the form i get error... as ...

Validation Error : Value is required
Validation Error : Value is required


I customised the error now i get...

Field1 is required
Field2 is required

on top of the screen as i am including the tag there.

Now the problem is that...
I should get message dispalyed as


Field1 is required
Field2 is required

Field1 and Field2 in above messages are hyperlinks.

when i click on either, it should point to the textboxes in the page...

Hyperlink within a page...
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if this is the solution, but did you try putting the <f:verbatim> tags with HTML hyperlink code in the message String?
 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all how are you identifying the fields as Field1 and Field2? I dont think JSF at least MyFaces is not capable of displaying the field names in the validation messages. Are you using any PhaseListeners?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For identifying the fields, you can use the "id" attribute of each field and in the <h:message> give the id of the required field as

 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you will know the id, but not the field name. For example: you will not be able to display "Value is required for User Id" where user Id is the field. You can only display "Value is required".
But you may use Phase Listeners to identify the field names also as given here

Let me know if it helped you.
 
This is my favorite show. And this is my favorite tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic