when to use pretty:link rather than h:commandLink

Splash Forums PrettyFaces Users when to use pretty:link rather than h:commandLink

This topic contains 6 replies, has 2 voices, and was last updated by  mika 10 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #18062

    mika
    Participant

    hi

    i want to add url to navigate from page that views all users to a page that add new user

    and i am confused between using h:commandLink and pretty:link

    1- can anyone tell me the difference when to use this one or the other one, and in my exact case what to use.

    2- is pretty:link makes redirect or forward ?

    thanks.

    #21592

    Hey mika,

    The h:commandLink component is used to execute actions on the server side. So JSF will ALWAYS perform a postback to the server and then executed the action referenced by the action attribute. This is even the case if you directly enter an action outcome in the action attribute of the commandLink. So if you use a h:commandLink you will always perform a postback followed by a redirect to the target page. I don’t recommend to use this pattern if you don’t have any code to be executed on the server side and just want to redirect the user to some target page.

    The pretty:link component renders a simple HTML link instead. So clicking this link will take the user directly to the target page without any postback. This is the preferred pattern if you simply want to get the user to the target page.

    Christian

    #21593

    mika
    Participant

    @Christian, thanks a lot for the detailed info but you didn’t answered my second question.

    #21594

    Sure I did. The pretty:link component creates a standard HTML link tag for the target URL. So clicking this link will result in a simple GET request to the “pretty” URL. So there is no redirect.

    #21595

    mika
    Participant

    but it changes the current url to the desired url, right ?

    #21596

    Yes! It links to the pretty URL of the target mapping!

    #21597

    mika
    Participant

    Thanks Christian.

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.