我想接收自定义组件的Value参数类型为ArrayList的值,已经创建了独立的渲染器.可是不知道怎么在自定义component类和渲染器,怎么处理? 
我的标签是这样定义的. 
<s:scheduleshow id="price2" value="#{vschedulebean.lstSchedules}"> </s:scheduleshow> 
我想要的效果是...想自定义一个控件显示数据,现在存在下列疑问: 
1,数据来源于#{vschedulebean.lstSchedules},不知道定义组件类的时候是不是该继承自UIInput; 
2,这个lstSchedules的类型为ArrayList <VoyageSchedule>,不知道tld文件里面是不是要配置type属性为java.util.ArrayList,也不知道在tag类里面该用什么类型接收,是object还是ArrayList; 
3,三个类:自定义组件,渲染器,组件控制类之间是怎样的流程来处理ArrayList的? 
如果能解答我心中的疑问的,加80分...散分!

解决方案 »

  1.   

    没人回答...难道说...懂JSF的这么少吗???
      

  2.   

    在自定义tag类里面重写方法setProperties
    @Override
    protected void setProperties(UIComponent component1) {
    ScheduleshowComponent component=(ScheduleshowComponent) component1;
    logger.info("setProperties function");
    super.setProperties(component);
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    ValueBinding binding = application.createValueBinding(value);
    System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
    component.setValueBinding("value", binding);
    if (isValueReference(value)) {      
      component.setValueBinding("value", binding);
      }
    在自定义渲染器里面:写个方法(方法名自编)
    private void encodeTableInLeftContainer(ResponseWriter writer,
    ScheduleshowComponent fieldComponent) throws IOException {
    FacesContext currentInstance = FacesContext.getCurrentInstance();
    List<Voyageschedule> sss=new ArrayList<Voyageschedule>()  ;
    Object obj=fieldComponent.getValueBinding("value");

    if (obj!= null) { 
    logger.info("obj!=null");
      ValueBinding vb = fieldComponent.getValueBinding("value"); 
      if (vb != null) { 
     logger.info("vb!=null");
    sss= (List<Voyageschedule>) vb.getValue(currentInstance); 
      }     
      else
      {
    logger.info("vb==null");
    sss=(ArrayList<Voyageschedule>) fieldComponent.getValue(); 
      }
    }  
    this.setLst(sss);
    if(this.getLst().size()>0)
    {
    if (this.getLstp() != null) {
    int size = this.getLstp().size();
    if (size > 0) {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
     
    writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
    .getLstp()); writer.endElement("table");
    } else {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
    writer.writeAttribute("style", style2, "style");
    writer.startElement("tr", fieldComponent);
    writer.startElement("td", fieldComponent);
    writer.writeAttribute("text", "/-/-/", "text");
    writer.endElement("td");
    writer.endElement("tr");
    writer.endElement("table");
    }
    } else {
    logger.info("this.getLst().value==null");
    }
    }

     
    }
      

  3.   

    在自定义tag类里面重写方法setProperties
    @Override
    protected void setProperties(UIComponent component1) {
    ScheduleshowComponent component=(ScheduleshowComponent) component1;
    logger.info("setProperties function");
    super.setProperties(component);
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    ValueBinding binding = application.createValueBinding(value);
    System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
    component.setValueBinding("value", binding);
    if (isValueReference(value)) {      
      component.setValueBinding("value", binding);
      }
    在自定义渲染器里面:写个方法(方法名自编)
    private void encodeTableInLeftContainer(ResponseWriter writer,
    ScheduleshowComponent fieldComponent) throws IOException {
    FacesContext currentInstance = FacesContext.getCurrentInstance();
    List<Voyageschedule> sss=new ArrayList<Voyageschedule>()  ;
    Object obj=fieldComponent.getValueBinding("value");

    if (obj!= null) { 
    logger.info("obj!=null");
      ValueBinding vb = fieldComponent.getValueBinding("value"); 
      if (vb != null) { 
     logger.info("vb!=null");
    sss= (List<Voyageschedule>) vb.getValue(currentInstance); 
      }     
      else
      {
    logger.info("vb==null");
    sss=(ArrayList<Voyageschedule>) fieldComponent.getValue(); 
      }
    }  
    this.setLst(sss);
    if(this.getLst().size()>0)
    {
    if (this.getLstp() != null) {
    int size = this.getLstp().size();
    if (size > 0) {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
     
    writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
    .getLstp()); writer.endElement("table");
    } else {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
    writer.writeAttribute("style", style2, "style");
    writer.startElement("tr", fieldComponent);
    writer.startElement("td", fieldComponent);
    writer.writeAttribute("text", "/-/-/", "text");
    writer.endElement("td");
    writer.endElement("tr");
    writer.endElement("table");
    }
    } else {
    logger.info("this.getLst().value==null");
    }
    }

     
    }
      

  4.   

    在自定义tag类里面重写方法setProperties
    @Override
    protected void setProperties(UIComponent component1) {
    ScheduleshowComponent component=(ScheduleshowComponent) component1;
    logger.info("setProperties function");
    super.setProperties(component);
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    ValueBinding binding = application.createValueBinding(value);
    System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
    component.setValueBinding("value", binding);
    if (isValueReference(value)) {      
      component.setValueBinding("value", binding);
      }
    在自定义渲染器里面:写个方法(方法名自编)
    private void encodeTableInLeftContainer(ResponseWriter writer,
    ScheduleshowComponent fieldComponent) throws IOException {
    FacesContext currentInstance = FacesContext.getCurrentInstance();
    List<Voyageschedule> sss=new ArrayList<Voyageschedule>()  ;
    Object obj=fieldComponent.getValueBinding("value");

    if (obj!= null) { 
    logger.info("obj!=null");
      ValueBinding vb = fieldComponent.getValueBinding("value"); 
      if (vb != null) { 
     logger.info("vb!=null");
    sss= (List<Voyageschedule>) vb.getValue(currentInstance); 
      }     
      else
      {
    logger.info("vb==null");
    sss=(ArrayList<Voyageschedule>) fieldComponent.getValue(); 
      }
    }  
    this.setLst(sss);
    if(this.getLst().size()>0)
    {
    if (this.getLstp() != null) {
    int size = this.getLstp().size();
    if (size > 0) {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
     
    writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
    .getLstp()); writer.endElement("table");
    } else {
    writer.startElement("table", fieldComponent);
    String style2 = "color:#000000;background-color:#99CCFF;width:"
    + this.leftdivwidth
    + "px;height:"
    + this.containerdivheight + "px;";
    writer.writeAttribute("style", style2, "style");
    writer.startElement("tr", fieldComponent);
    writer.startElement("td", fieldComponent);
    writer.writeAttribute("text", "/-/-/", "text");
    writer.endElement("td");
    writer.endElement("tr");
    writer.endElement("table");
    }
    } else {
    logger.info("this.getLst().value==null");
    }
    }

     
    }