You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ramesh bodimani <ra...@gmail.com> on 2005/06/21 14:44:33 UTC

Tag-Bug

MyFaces Discussion
I am planning to write a simple component, 


My component will take one parameter from the tag through the Tag class.

I am using my tag in the jsp page like this: 

<test:testTag jspID="<%=request.getParameter("id")%>">

My Tag class is like this:

public class TestTag extends UIComponentTag {

	private String jspID = null;

	public String getRendererType() {
        return null;
	}

	public String getComponentType() {
        return "com.tags.BreadCrumbs";
	}

	public void setJspID(String jspID) {
        this.jspID = jspID;
	}

	public void setProperties(UIComponent component) {
        // always call the superClass method first
        super.setProperties(component);	          
        setString(component, "jspID", jspID);
	}

	public void setString(UIComponent component, String attributeName,
            String attributeValue) {
        if (attributeValue == null)
            return;
        if (isValueReference(attributeValue)) {
            setValueBinding(component, attributeName, attributeValue);
        } else {
            component.getAttributes().put(attributeName, attributeValue);
        }
	}
	public void setValueBinding(UIComponent component, String attributeName,
            String attributeValue) {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        ValueBinding vb = app.createValueBinding(attributeValue);
        component.setValueBinding(attributeName, vb);
    }
    public void release() {
        super.release();      
		jspID = null;
    }
}
My Component class code is like this:

	public void encodeBegin(FacesContext context) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        String clientId = getClientId(context);
		String jspID = null;
		jspID = (String) getAttributes().get("jspID");
		System.out.println("jspID in Component class:"+jspID);
	}


If I call this component by changing id value, setProperties method is
not calling every time.

TIA,

Regards,
Ramesh