Re: when to use pretty:link rather than h:commandLink

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

#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