|
Hi The navigation system in JSF is enforced declaratively.
I was curious of Craig or any of the powers-that-be of myfaces had considered
using typesafe navigation using enums? We do this in a rudimentary way in our project, as
there is a very real chance of namespace mixups and misspelling: public class PersonnelBackingBean
{ public static enum
PersonnelOutcomes implements Outcomes { SAVE(“personnelSavePage”), CANCEL(“personnelManagePage”), ; private String value; private PersonnelOutcomes(String s) { this.value = s; } public String toString() { return value; } } //then in the
navigation action-listener public String
doSave() { return
PersonnelOutcomes.SAVE.toString(); } } I was wondering if the JSF or myfaces team had
considered using a typesafe way similar to this so that we can simply return an
enum instance and the framework can sort out if it is legitimate or not. A more
robust example (than the one above) might be: @FromViewId( “*”
) public enum PersonnelOutcomes
implements JSFOutcomes { SAVE(“savePersonnel”,
“/faces/personnel/save.jsp”); //etc. } Then in faces-config: <navigation-rule> <enum>com.mydomain.personnel.PersonnelOutcomes</enum> </navigation-rule> Anyway, thought I would raise it to see if people
find this interesting. I myself have a lot of trouble keeping the navigation
outcomes straight. In our projects (as in all projects) the view layer
experiences some namespace creep and occasionally undergoes navigation
refactoring. The enum system helps us keep our sanity. Of course this would
force all faces users to be JDK5 only, however, seeing as JSF is now part of
Java EE 5, I thought that we were headed down that path anyway and it might be
a sensible approach to take. Thanks, Dhanji
|

