// 编写处理Action事件的方法
 public void processAction(ActionEvent event) {
   // 获取当前的FacesContext对象
   FacesContext context = FacesContext.getCurrentInstance();
   // 获取JSF页面中<f:view.../>元素
   UIViewRoot viewRoot = context.getViewRoot();
   // 通过ID获取<f:view.../>内的<h:form.../>子元素。
   UIComponent comp = viewRoot.findComponent("addForm");
   // 通过ID获取<h:form.../>内的第一个<h:inputText.../>子元素。
   UIInput input = (UIInput) comp.findComponent("name");
   // 通过ID获取<h:form.../>内的第二个<h:inputText.../>子元素。
   HtmlInputText price = (HtmlInputText) comp.findComponent("price");
   if (input.getValue().equals("疯狂Java讲义")) {
     price.setSize(60);
     price.setValue("99.0元");
     price.setStyle("background-color:#9999ff;" + "font-weight:bold");
   }
 }
  public static UIViewRoot findRoot(FacesContext context, ServletRequest req, Object etag)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    UIViewRoot root = context.getViewRoot();

    if (root == null)
      throw new NullPointerException(L.l("f:view can't find current in FacesContext"));

    Object oldETag = root.getAttributes().get("caucho.etag");

    if (oldETag != null && !oldETag.equals(etag)) {
      // clear view on JSP change

      root.getChildren().clear();
      root.getFacets().clear();
    }

    root.getAttributes().put("caucho.etag", etag);

    return root;
  }