Custom Component
I've a problem extendign the UISelectOne component... My classes: package holderTagClasses; import javax.faces.application.Application; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.el.MethodBinding; import javax.faces.el.ValueBinding; import javax.faces.event.ValueChangeEvent; import javax.faces.webapp.UIComponentTag; public class BDE_IAS_ComboTag extends UIComponentTag{ String lista; String listaValores; String value; String valueChangeListener; public String getValueChangeListener() { return valueChangeListener; } public void setValueChangeListener(String valueChangeListener) { this.valueChangeListener = valueChangeListener; } public void setLista(String lista){ this.lista=lista; } public String getLista(){ return lista; } public void setListaValores(String lista){ this.listaValores=lista; } public String getListaValores(){ return listaValores; } public void setValue(String valor){ this.value=valor; } public String getValue(){ return value; } public void release() { // the super class method should be called super.release(); lista=null; value=null; valueChangeListener=null; listaValores=null; } protected void setProperties(UIComponent component) { super.setProperties(component); if (lista != null) { if (isValueReference(lista)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(lista); component.setValueBinding("lista", vb); } else { if(lista.length()==0){ lista=null; } else{ component.getAttributes().put("lista",lista); } } } if (listaValores != null) { if (isValueReference(listaValores)) { ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(listaValores); component.setValueBinding("listaValores", vb); } else { if(listaValores.length()!=0){ component.getAttributes().put("listaValores",listaValores); } else{ if(lista!=null){ if(lista.length()>0){ ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(lista); component.setValueBinding("listaValores", vb); } } } } } if (value!=null) { if (isValueReference(value)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(value); component.setValueBinding("value", vb); } else { if(value.length()==0){ value=null; } else{ component.getAttributes().put("value",value); } } } if (valueChangeListener != null) { if (isValueReference(valueChangeListener)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = app.createMethodBinding(valueChangeListener, new Class[] { ValueChangeEvent.class }); component.getAttributes().put("valueChangeListener", mb); } } } public String getRendererType() { return "combo"; } public String getComponentType() { return "combo"; } } package rendererClasses; import java.io.IOException; import java.util.ArrayList; import java.util.Map; import javax.faces.component.EditableValueHolder; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.render.Renderer; public class ComboRenderer extends Renderer{ public void
Re: Custom Component
JAVA IS 1.4 I'm not using myFaces Original Message Follows From: Udo Schnurpfeil <[EMAIL PROTECTED]> Reply-To: "MyFaces Discussion" To: MyFaces Discussion Subject: Re: Custom Component Date: Thu, 15 Sep 2005 12:30:49 +0200 Hi! What is the Java version? What is the MyFaces version? Udo Goyo Escobar Escalero wrote: I've a problem extendign the UISelectOne component... My classes: package holderTagClasses; import javax.faces.application.Application; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.el.MethodBinding; import javax.faces.el.ValueBinding; import javax.faces.event.ValueChangeEvent; import javax.faces.webapp.UIComponentTag; public class BDE_IAS_ComboTag extends UIComponentTag{ String lista; String listaValores; String value; String valueChangeListener; public String getValueChangeListener() { return valueChangeListener; } public void setValueChangeListener(String valueChangeListener) { this.valueChangeListener = valueChangeListener; } public void setLista(String lista){ this.lista=lista; } public String getLista(){ return lista; } public void setListaValores(String lista){ this.listaValores=lista; } public String getListaValores(){ return listaValores; } public void setValue(String valor){ this.value=valor; } public String getValue(){ return value; } public void release() { // the super class method should be called super.release(); lista=null; value=null; valueChangeListener=null; listaValores=null; } protected void setProperties(UIComponent component) { super.setProperties(component); if (lista != null) { if (isValueReference(lista)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(lista); component.setValueBinding("lista", vb); } else { if(lista.length()==0){ lista=null; } else{ component.getAttributes().put("lista",lista); } } } if (listaValores != null) { if (isValueReference(listaValores)) { ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(listaValores); component.setValueBinding("listaValores", vb); } else { if(listaValores.length()!=0){ component.getAttributes().put("listaValores",listaValores); } else{ if(lista!=null){ if(lista.length()>0){ ValueBinding vb =FacesContext.getCurrentInstance().getApplication().createValueBinding(lista); component.setValueBinding("listaValores", vb); } } } } } if (value!=null) { if (isValueReference(value)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(value); component.setValueBinding("value", vb); } else { if(value.length()==0){ value=null; } else{ component.getAttributes().put("value",value); } } } if (valueChangeListener != null) { if (isValueReference(valueChangeListener)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = app.createMethodBinding(valueChangeListener, new Class[] { ValueChangeEvent.class }); component.getAttributes().put("valueChangeListener", mb); } } } public String getRendererType() { return "combo"; } public String getComponentType() { return "combo"; } } package rendererClasses; import java.io.IOException; import java.util.ArrayList; import java.util.Map; import javax.faces.component.EditableValueHolder; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.render.Renderer; public class ComboRenderer extends Renderer{ public void encodeBegin(FacesContext context, UIComponent combo) throws IOException { ResponseWriter writer = context.getResponseWriter(); char salto ='\n'; try{ //ArrayList lista = (ArrayList)getLista(); ArrayLis
rendering a custom component
If I have inside of my encodeBegin method a UISelectOne object... how can I render it??
ValueChangeListener another time...
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??
RE: javax.faces.el.PropertyNotFoundException: Base is null when upgrading to 1.1.0?
try to call the property with lower case, I mean... "beanClass.base" From: Bjørn T Johansen <[EMAIL PROTECTED]>Reply-To: "MyFaces Discussion" To: MyFaces Discussion Subject: javax.faces.el.PropertyNotFoundException: Base is null when upgrading to 1.1.0?Date: Wed, 21 Sep 2005 12:15:17 +0200I am trying to upgrade my application to 1.1.0 but when I do, I get this exception.:javax.faces.el.PropertyNotFoundException: Base is null: loginBeanorg.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:457)org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:169)com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:111)javax.faces.component.UIInput.getConvertedValue(UIInput.java:713)javax.faces.component.UIInput.validate(UIInput.java:638)javax.faces.component.UIInput.executeValidate(UIInput.java:849)javax.faces.component.UIInput.processValidators(UIInput.java:412)javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)javax.faces.component.UIForm.processValidators(UIForm.java:170)javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)javax.faces.compo nent.UIViewRoot.processValidators(UIViewRoot.java:342)org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:208)org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:280)What am I missing?Regards,BTJ-Bjørn T Johansen[EMAIL PROTECTED]---Someone wrote:"I understand that if you play a Windows CD backwards you hear strange Satanic messages"To which someone replied:"It's even worse than that; play it forwards and it installs Windows"---
How can I include IBM components into mines ones
I need, for example, a 4 buttons component, but i'd like to use the IBM buttons to do it. Could someone write me any code to do it or the way to do it??