I want to develop a comboBox wich ge 2 arrayList, one for the labels and one for the values, that's ok, I do it with those methods...
 
public void encodeBegin(FacesContext context) throws IOException {
  ResponseWriter writer = context.getResponseWriter();
  char salto = '\n';
  try {
   ArrayList lista = (ArrayList)getLista();
   ArrayList listaValores = new ArrayList();
   ;
   if (lista != null) {
    listaValores = (ArrayList) this.getAttributes().get(
      "listaValores");
    if (listaValores == null) {
     listaValores = lista;
    } else {
     if (listaValores.size() == 0) {
      listaValores = lista;
     }
    }
   }
   
   ArrayList list = new ArrayList();
   Application app = context.getApplication();
   
   HtmlSelectOneListbox comb = new HtmlSelectOneListbox();
   
   int i = 0;
   String valor = "";
   valor = (String) this.getAttributes().get("value");
   for (i = 0; i < lista.size(); i++) {
    UISelectItem sel = new UISelectItem();
    sel.setItemValue(listaValores.get(i));
    sel.setItemLabel((String) lista.get(i));
    String selected="selected";
    comb.getChildren().add(sel);
   }
   
   comb.setId(this.getId());
   comb.setSize(1);
   comb.setStyleClass("comboBox");
    
   
   comb.decode(context);
   try {
    renderChild(context, comb);
   } catch (IOException e) {
    e.printStackTrace();
   }
  } catch (Exception e) {
   System.out.println(e);
  }
 }
 public static void renderChild(FacesContext facesContext, UIComponent child)
   throws IOException {
  if (!child.isRendered()) {
   return;
  }
  child.encodeBegin(facesContext);
  if (child.getRendersChildren()) {
   child.encodeChildren(facesContext);
  } else {
   renderChildren(facesContext, child);
  }
  child.encodeEnd(facesContext);
 }
 public static void renderChildren(FacesContext facesContext,
   UIComponent component) throws IOException {
  if (component.getChildCount() > 0) {
   for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
    UIComponent child = (UIComponent) it.next();
    renderChild(facesContext, child);
   }
  }
 }
 
Now I want to add it a valueChangeLisntener... but I'm unable to do it... for this I have the next method at the tag-class
 
protected void setProperties(UIComponent component) {
  super.setProperties(component);
  BDE_IAS_UICombo listaMenu=(BDE_IAS_UICombo) component;
  
  if (lista != null) {
   if (isValueReference(lista)) {
    ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(lista);
    listaMenu.setValueBinding(BDE_IAS_UIComboBox.LISTA_VB, vb);
   } else {
    if(lista.length()==0){
     lista=null;
    }
    else{
     listaMenu.setLista(lista); 
    }
   }
  }
  
  if (listaValores != null) {
   if (isValueReference(listaValores)) {
    ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(listaValores);
    listaMenu.setValueBinding(BDE_IAS_UIComboBox.LISTAVALORES_VB, vb);
   } else {
    if(listaValores.length()!=0){
     listaMenu.setListaValores(listaValores);
    }
    else{
     if(lista!=null){
      if(lista.length()>0){
       ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(lista);
       listaMenu.setValueBinding(BDE_IAS_UIComboBox.LISTA_VB, vb);
      }
     }
    }
   }
  }
  
  if (valueChangeListener != null) {
            if (isValueReference(valueChangeListener)) {
             FacesContext context = FacesContext.getCurrentInstance();
             Application app = context.getApplication();
             MethodBinding mb = app.createMethodBinding(valueChangeListener, new Class[] { ValueChangeEvent.class });
             listaMenu.setValueChangeListener(mb);
            }
        } 
 }
 
Debugging I'm sure taht the alue of the methodBinding is ok, but the methodisn't executed....
 
WHATH HAVE I TO DO??? Please help me...;-)
 
One more thing, If I want to select one of the item by default, how can I implement it?? I would pass the component a value, whin matches with an itm of the list, and then it must be selected... is it possible??

Reply via email to