Hi ,
I want to create a custom tag with binding attribute.In the
customTagClass i put property binding .
The Tag class is:
public class CustomPanelGridTag extends HtmlPanelGridTag{
private String paginator;
private String binding;
public void setBinding(String binding) {
this.binding = binding;
}
public void setPaginator(String paginator) {
this.paginator = paginator;
}
public String getComponentType() {
return CustomPanelGrid.COMPONENT_TYPE;
}
public String getRendererType()
{
return "javax.faces.Grid";
}
protected void setProperties(UIComponent component) {
super.setProperties(component);
setString(component,"paginator",paginator);
// I tried by putting setString(component,"binding","binding")
}
public void release() {
super.release();
}
public void setString(UIComponent component, String attributeName,
String attributeValue) {
if (attributeValue == null) {
return;
}
if (isValueReference(attributeValue)) {
System.out.println("attributeName"+attributeValue);
setValueBinding(component, attributeName, attributeValue);
} else {
System.out.println("attributeNameattr"+attributeValue);
component.getAttributes().put(attributeName,
attributeValue);
}
}
/**
* sets the value binding of an atttibute
* @param component
* @param attributeName
* @param 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);
}
}
Component binding is not working with this binding property.
I even tried putting
try {
super.setBinding(binding);
} catch (JspException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
in set Properties method of this tag,then also component instance binding is
not done.
Please let me help in knowing what to do if we want to have a binding
property in the custom tag.It will be great help if any body tell how the
binding propery works done in JSF.To my knowledge , _jspService method
calls the UIComponentTag.setBinding... and after that
UIComponentTag.createComponentInstance is called to create the component
with the instance given by binding property.
Thanks,
Rajeshekar