On 6/17/06, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>From: "Sean Schofield" <[EMAIL PROTECTED]> > > I am writing an application that is using MyFaces tree2 to allow the > user to navigate to a more detailed view of the item they click on. I > just wanted some feedback on the following strategy: > > The node in the tree has an action method that puts the selected > node's id into the request as a parameter. The String returned by the > action method navigates you to a general detail page which is > associated with a ViewController. The vc's init() method reads the > node id out of the request and pulls the necessary info out of the > data. > > Does this general approach make sense? > I think that's exactly what the extra callbacks on the view controller should be used for. You could use the setter injections stuff on a managed bean to grab the values out of the request but without the view controller, you wouldn't have a good hook for pre process or staging logic since the view root doesn't have these kind of events.
While biulding a Shale-based prototype application recenty, I ran into a gotcha with respect to the setter injection stuff when you don't actually have a request parameter on the incoming request. If you use "#{param.foo}" as your managed property's <value> element, and there is no request parameter named "foo", the RI (at least) will throw an exception when trying to do the value push. (Didn't have time to confirm whether MyFaces acts the same way). One could argue that this is a usability issue that should be addressed even if the spec is silent on the topic. But, in the mean time, I'm doing exactly what Sean describes (copy the request parameters in the init() callback) to pull out these sorts of values. Indeed, if you use the latest sources (in the Maven-generated buld that we just switched to), I've added the following convenience method to AbstractFacesBean (ancestor to AbstractViewController) to make this kind of thing a bit simpler to code: public String getRequestParameter(String parameterName);
TIA, > > Sean Gary
Craig