Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 51787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:48:18+00:00 2026-05-10T16:48:18+00:00

Is there a way to create an html link using h:outputLink, other JSF tag

  • 0

Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters?

For example I have the following navigation-rule

<navigation-rule>     <navigation-case>         <from-outcome>showMessage</from-outcome>         <to-view-id>/showMessage.jsf</to-view-id>         <redirect/>     </navigation-case> </navigation-rule> 

In my page I would like to output the following html code:

<a href='/showMessage.jsf?msg=23'>click to see the message</a> 

I could just write the html code in the page, but I want to use the navigation rule in order to have all the urls defined in a single configurable file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:48:19+00:00Added an answer on May 10, 2026 at 4:48 pm

    This is an interesting idea. I’d be curious to know how it pans out in practice.

    Getting the navigation rules

    Navigation is handled by the NavigationHandler. Getting hold of the NavigationHandler isn’t difficult, but the API does not expose the rules it uses.

    As I see it, you can:

    1. parse faces-config.xml on initialization and store the rules in the application context (easy)
    2. implement your own NavigationHandler that ignores the rules in faces-config.xml or supplements them with your own rules file and exposes its ruleset somehow (workable, but takes a bit of work)
    3. mock your own FacesContext and pass it to the existing navigation handler (really difficult to make two FacesContext object coexist in same thread and extremely inefficient)

    Now, you have another problem too. Where are you going to keep the mappings to look up the views? Hard-code them in the beans?

    Using the navigation rules

    Off hand, I can think of two ways you could construct parameter-containing URLs from the back-end. Both involve defining a bean of some kind.

    <managed-bean>     <managed-bean-name>navBean</managed-bean-name>     <managed-bean-class>foo.NavBean</managed-bean-class>     <managed-bean-scope>application</managed-bean-scope> </managed-bean> 

    Source:

    package foo;  import java.io.IOException; import java.io.Serializable; import java.net.URLEncoder;  import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext;  public class NavBean implements Serializable {      private String getView() {         String viewId = '/showMessage.faces'; // or look this up somewhere         return viewId;     }      /**      * Regular link to page      */     public String getUrlLink() {         FacesContext context = FacesContext.getCurrentInstance();         ExternalContext extContext = context.getExternalContext();         String viewId = getView();         String navUrl = context.getExternalContext().encodeActionURL(                 extContext.getRequestContextPath() + viewId);         return navUrl;     }      /**      * Just some value      */     public String getValue() {         return '' + System.currentTimeMillis();     }      /**      * Invoked by action      */     public String invokeRedirect() {         FacesContext context = FacesContext.getCurrentInstance();         ExternalContext extContext = context.getExternalContext();         String viewId = getView();         try {             String charEncoding = extContext.getRequestCharacterEncoding();             String name = URLEncoder.encode('foo', charEncoding);             String value = URLEncoder.encode(getValue(), charEncoding);             viewId = extContext.getRequestContextPath() + viewId + '?' + name                     + '=' + value;             String urlLink = context.getExternalContext().encodeActionURL(                     viewId);             extContext.redirect(urlLink);         } catch (IOException e) {             extContext.log(getClass().getName() + '.invokeRedirect', e);         }         return null;     }  } 

    GET

    For a GET request, you can use the UIParameters to set the values and let the renderer build the parameter list.

    <h:outputLink value='#{navBean.urlLink}'>     <f:param name='foo' value='#{navBean.value}' />     <h:outputText value='get' /> </h:outputLink> 

    POST

    If you want to set the URL to a view during a POST action, you can do it using a redirect in an action (invoked by a button or commandLink).

    <h:commandLink id='myCommandLink' action='#{navBean.invokeRedirect}'>     <h:outputText value='post' /> </h:commandLink> 

    Notes

    Note that ExternalContext.encodeActionURL is used to encode the string. This is good practice for producing code that is portable across contexts (portlets, etcetera). You would use encodeResourceURL if you were encoding a link to an image or download file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the array_combine function, like so: $numbers =… May 12, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer This is a shortcoming of the FTP client that comes… May 12, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer "What's the simplest solution to 'remember' the state of the… May 12, 2026 at 1:10 am

Related Questions

I have an ASP.NET MVC project and I have a single action that accepts
I have a struts2 application with a single page that may show one of
Need: Find a way to add a valid tag/attribute/property to a normal html control.
I'm attempting to send HTML formatted emails using C# 3 via Outlook.MailItem Outlook.MailItem objMail

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.