UICommand linkdanweimc = (UICommand) (root.findComponent("searchid").findComponent("units").findComponent("toDetail"));可以获取一个UICommand控件的值但是一个普通的控件怎么获取?

解决方案 »

  1.   

    普通控件的值不是已经在你的backbean中定义好了吗,你可是直接用的啊.
      

  2.   

    public void reset(javax.faces.event.ActionEvent e){
         
         ((LocalDataModel)dataModel).resetPage(0,50);
         
         FacesContext facesContext = FacesContext.getCurrentInstance();
         
         UIComponent c =facesContext.getViewRoot();
         
         UIData data=null;
         
         String name="frmData:userList";
            c=findComponent(c,name,facesContext);
         
         if (c!=null){
         data=(UIData)c;
         data.setFirst(0);
         }
         
        } 
        private  UIComponent findComponent(UIComponent component, String id, 
         FacesContext context) {
          String componentId = component.getClientId(context);    if (componentId.equals(id)) return component;
       Iterator kids = component.getChildren().iterator();
       while (kids.hasNext()) {
           UIComponent kid = (UIComponent) kids.next();
       UIComponent found = findComponent(kid, id, context);
       if (found != null) return found;
       }
       return null;
    }       
    這是個找datatable的函數,看看吧