Recent Changes - Search:

WebFacets

HOW-TOs

Authentication



SourceForge Logo









YourKit Java Profiler

WritingFacets

Writing web-enabled facets is strictly similar to write facets in regular Java applications. Of course, you can write your facets the Java or the Groovy way, or both !

One thing has to be noticed. With the extended web facet context, you can access the javax.serlvet.http.* objects from your facet code if needed.

From pure Java facets :

/**
 * A facet that does things with the request
 */

public class MyWebFacet implements IFacet {

  /** web-enabled facet context */
  private IWebFacetContext context;

  /** from IFacet */
  public IWebFacetContext getContext() {
    return context;
  }

  /** from IFacet */
  public void setContext(IFacetContext context) {
    this.context = (IWebFacetContext)context;
  }

  public void doStuff() {
    // get the request
    HttpServletRequest request = getContext().getRequest();
    request.setAttribute("myFacet", this);
    String param = request.getParameter("param");
    ...

  }

}

From Groovy Facets :

/*
 * Executable groovy script
 */

o = ... ;
context.request.setAttribute("something", o);
p = request.getParameter("param");
...

Edit - History - Print - Recent Changes - Search
Page last modified on April 14, 2007, at 07:53 PM