WebFacetsHOW-TOsAuthentication
YourKit Java Profiler |
ViewResolversThis "pattern" allows to implement profile-based navigation and rendering, by selecting appropriate views for given profiles. This is one of the most common usages of WebFacets. Basically, you simply use facets to decide which view to be used to render a particular page (or part of it - see CompositePages). The controller, when the job is done, simply retrieves a facet and invokes it to get the view to dispatch to (if you don't need no pre-controller, look at ViewHelpers). It goes more or less like :
Here under is a code snippet that shows how the view can be resolved using a facet, from inside a fictious servlet (or an action in an MVC framework) : // somewhere in a servlet, we get the jFacets bean... WebFacets wf = WebFacetsFilter.getJFacets(request); // we execute a facet that returns the path to a JSP String path = wf.execFacet("view", profileId, anObject); // and we forward to it request.getRequestDispatcher().forward(request, response); Of course, you could have the same inside a JSP, using the WebFacets taglib : <wf:execFacet name="view" profileId="${profileId}" targetObject="${anObject}" var="path"/> <jsp:forward page="${path}"/> View abstractionOf course, every view technology has its specificities and is manipulated differently from controllers. Some use request dispatch (Struts, Stripes, WW, etc.) , others use "component renderers" (JSF, Echo, etc.), so there's no one-size-fits-all solution for a integration of facets to all of them. But since facets are very simple and are just POJOs, you should be able to write a few lines of code to wrap everything and use facet-based view resolution. You can have a look to the Examples?, there is a very basic implementation of this pattern using plain JSPs. In order to provide a ready-to-use solution, a base |