views:

17

answers:

0

I have an .xhtml page that is processed by the faces servlet in Tomcat. GET requests to the page look like this /module.xhtml?mod=6. I need to validate the integer parameter 'mod'. 'mod' is the ID of the Module object which is to be displayed on the module.xhtml page. Here's what I have far in module.xhtml:

<f:metadata>
 <f:viewParam validator="#{Modules.validate}" name="mod" value="#{Modules.currentModule}" />
</f:metadata>

The validator method runs first and does an HTTP redirect to the module selection page if the module ID does not map to a valid module. The declaration of Modules.currentModule is:

public void setCurrentModule( int module_ID )

This all works fine. The part I'm not sure about is how to display the selected module in the module.xhtml page. I've tried doing something like this in the Modules class:

public Module getCurrentModule()

then using #{Modules.currentModule.name}, etc. However this gives a conversion error. So my question is two-fold. How do I display the selected module in the module.xhtml page, and is the above method the best way of going about this or is there or more efficient mechanism?