Re: URLMapping pattern vs query parameters

Splash Forums PrettyFaces Users URLMapping pattern vs query parameters Re: URLMapping pattern vs query parameters

#21214

Hey Matt,

thanks for your detailed response. I’ll try to make my point more clear.

Actually I think there are two different types of navigation that you may want to perform:

  1. Sometimes you may want to click a button and want an action method on the server to be executed to do some stuff. After the action method has done its job you want to navigate to some other page. A typical example is a “delete” button. You want to execute server side code to delete the entry from the database and then redirect the user to some other page.
  2. In the other case you don’t want to execute any server side code and just send the user to a new page. A typical example is a “details” button. You click on the “details” button of an item and want the user to get redirected to a page containing all the details of this item.

    I actually think that the example of the thread author belongs to the second type. There is no need to execute any server side code if the user clicks on the edit button (at least it is my understanding of the usecase). He should just get redirected to the “edit” page of the account. Of cause the required data for the “edit” page has to be loaded from the DB and all the stuff, but this should be done by the editing page using a page action or something like this so that the page works independently from other pages.

    Because you don’t want to execute code on the server you actually don’t need to do a post back and could create just a standard HTML link which sends the user to the editing page. As described in my previous post this currently works only well with HTML links.

    But if you want to execute some action on the server when the button is clicked (think of the “delete entry” example) a commandButton or commandLink make sense. The action method can do its job and the only remaining question is how to redirect the user to the correct page. The typical PrettyFaces solution for this is that what Lincoln suggested. Set the properties of the target mapping and return the correct mapping id. PrettyFaces will then build the correct URL by reading all values out of the bean.

    I think it is really important to understand the difference between the two types of usecases I described. Either your primary goal is to get the user to another page (use pretty:link for creating a HTML link) or you want some action to be executed and redirect the user to some other page as a result (use commandButton).

    What do you think? Does this make sense for you?

    Christian