On 12/21/05, Alexandre Poitras <[EMAIL PROTECTED]> wrote: > > I see and I understand your point and I do think you're right. But I > had a lot of problems with url before. For instance, how can I relate > an url to the current selected item in the navigation menu. Am I > suppose not to care about it? Seems weird to me. Or should I maintain > a mapping between url and menu elements. I guess it is the right > answer but it is still confusing to me right now.
Is your *user* going to care about the URL (by bookmarking it)? If so, you need to worry about mapping URLs (possibly with request parameters to define the state) to a corresponding view. BUT if this is not the case, there is no reason for you to have to care either :-). Instead, you should focus on making sure the user gets directed to the correct view of your application, with the correct state information preceeding it. Just as a concrete example, consider a "Customer Orders" table view, where you want to make the order numbers a hyperlink to the corresponding order details. It would be common in a Struts 1.x world to see developers worried about creating a loop to render each row of the table, passing the order identifier as a request parameter on the detail URL for the hyperlinks inside each row ... indeed, the standard MailReader example acts this way. That's because Struts doesn't have any concept of complex UI components. In a typical JSF implementation of the same scenario, you would simply declare *one* <h:commandLink> component in the appropriate column of an <h:dataTable> component (no loops visible in the JSP source). The component itself would take care of the iteration across all the rows for each order ... and, more importantly, it makes sure that -- when the one-and-only action method for the hyperlink is executed -- the data model has been scrolled to the corresponding row. All you have to do then is stash away the primary key for the order in the current row, and then forward control to the order details page. No muss, no fuss ... and no URL construction :-). If you have a decent library of JSF components, then you are working too hard if you have iteration loops to render a table, or calculated URLs, in your JSP pages. Let the components manage all that administrivia for you, and focus on the logic that is unique to your application. Craig