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 8591381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:30:56+00:00 2026-06-11T23:30:56+00:00

I am maintaining a JSF2 Ajax application and we are heavily using h:commandLinks and

  • 0

I am maintaining a JSF2 Ajax application and we are heavily using h:commandLinks and f:ajax tags for all actions – always only rerendering what is needed.

This does of course break the expected behaviour for the user when performing a right click on the links and choosing “Open Link in New Tab” etc.

I understand that f:ajax forces the href atribute of the resulting a element to be # and does all the magic post request trickery in the onclick function – I now want to provide fallback support for the “Open Link…” action by putting some meaningful link in the href attribute of the resulting <a> tag.

This would not break the “normal” onclick behaviour as the generated javascript always finishes with return false; but would allow me to send my users to some page using a normal GET request in case they want to open the link in a new window.

Is there a build in way to do this? Or could somebody point me in the right direction on where in the JSF lifecycle I would have to jump in to do this maybe using a phase listener?

  • 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. Editorial Team
    Editorial Team
    2026-06-11T23:30:58+00:00Added an answer on June 11, 2026 at 11:30 pm

    Simplest would be to extend com.sun.faces.renderkit.html_basic.CommandLinkRenderer and override the renderAsActive() method accordingly. Mojarra is open source, just copy the method and edit the line where it says writer.write("href", "#", "href"). Replace the "#" string accordingly to your insight.

    public class MyCommandLinkRenderer extends CommandLinkRenderer {
    
        @Override
        protected void renderAsActive(FacesContext context, UIComponent command) throws IOException {
            // ...
        }
    
    }
    

    To get it to run, register it as follows in faces-config.xml:

    <render-kit>
        <renderer>
            <component-family>javax.faces.Command</component-family>
            <renderer-type>javax.faces.Link</renderer-type>
            <renderer-class>com.example.MyCommandLinkRenderer</renderer-class>
        </renderer>
    </render-kit>
    

    Note that this tight couples your renderer to Mojarra. To be JSF implementation independent, you’d need to create a whole new renderer instead of extending a Mojarra specific renderer class.


    Unrelated to the concrete problem, consider reading When should I use h:outputLink instead of h:commandLink?

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

Sidebar

Related Questions

I'm maintaining a Java web application that uses a java.util.Hashtable to cache values. This
currently I am maintaining a django web application and I am using rsync via
I am maintaining a web application that uses java.protocol.handler. I initialize it with a
I have a table maintaining record of all reservations made. Now the start date
I'm maintaining an open-source document asset management application called NotreDAM , which is written
I recently started maintaining an old EJB2 application running on OC4J. That includes EJB
I am maintaining an existing BlackBerry application (implemented as a MIDlet). The application contains
I am working on maintaining someone else's code that is using multithreading, via two
I'm maintaining a legacy site and on this site there is a weird mouseover
I'm maintaining a ActionScript 2 application which uses createEmptyMovieClip to create dropdown lists (the

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.