Re: URLMapping pattern vs query parameters

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




I’m not sure what you meant when you said that you want to prevent submitting forms. That notwithstanding, I think I see the larger disconnect here. :) Consider the following:

I have defined URLMappings a and b. View a contains a simple form which I want to submit, then (assuming no validation, etc., errors reported) go to view b. What I, as well as the OP, seem to be wanting to do is use pretty mappings consistently throughout our JSF application, thus h:commandButton action=”pretty:b”. Now say that b has a bean-mapped [path|query] parameter. The options now are:

1. Use f:param with action=”viewId from mapping b” (more or less duplicating the pretty mapping)

2. Use f:param with a logical outcome, mapped in faces-config.xml to the viewid from mapping b (again, more or less duplicating the pretty mapping)

3. Use an action method that sets the bean property and returns pretty:b (what Lincoln suggests; I have of course done this in places where I had _other_ stuff to do that was most simply expressed in Java code).

The duplication element makes options 1 and 2 unattractive and hopefully bears no further explanation. Option 3, as I have parenthetically hinted, seems like overkill for a simple situation. An additional option with regard to mapping a commandButton’s action to e.g. “pretty:b” is to add actionListeners to set the bean properties needed to create the final URL. This certainly works but feels a little ungainly.

What I plan to do personally is: create a SystemEventListener that responds to the PostConstructApplicationEvent by wrapping the default ActionListener with a pretty ActionListener that will check UICommand components for pretty mapping @actions in conjunction with attached UIParameters and attempt to handle these by setting the bean properties (and/or request parameters if needed/possible, haven’t researched that end yet).