Replace JSF tag by an own tag
Hi,
I'm trying to replace a <h:inputText> by my own tag. The used HtmlInputText component should not be replaced.
The reason is, that i want to pass permissions to the tag and map them to readonly and rendered attributes. My Problem is, that my own tag doesn't reolv bean values. If i use the <h:inputText> the bean values show up correctly. If i use my own tag, the input text shows "#{myBean.value}".
What could be the problem?
Thx in advance
Henrik
Here is my tag:
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputText;
import javax.faces.context.FacesContext;
import javax.faces.webapp.UIComponentTag;
import com.arvato.jsf.security.JSFSecurity;
import com.arvato.jsf.security.Permissions;
import com.sun.faces.taglib.html_basic.InputTextTag;
publicclass ArvatoTextFieldTagextends InputTextTag{
private String role;
private String onkeypress;
private String id;
private String value;
public String getRole(){
return role;
}
publicvoid setRole(String permissions){
this.role = permissions;
}
protectedvoid setProperties(UIComponent component){
super.setProperties(component);
if(id !=null){
component.getAttributes().put("id", id);
}
if(onkeypress !=null){
component.getAttributes().put("onkeypress", onkeypress);
}
if(value !=null){
component.getAttributes().put("value", value);
}
if(role !=null){
FacesContext facesContext = FacesContext.getCurrentInstance();
Permissions p = JSFSecurity.getInstance().getPermissionsForRole(role, facesContext);
if(!p.isWritable()){
component.getAttributes().put("readonly",true);
}
if(!p.isReadable()){
component.getAttributes().put("rendered",false);
}
}else{
component.getAttributes().put("readonly",false);
component.getAttributes().put("rendered",true);
}
}
@Override
public String getComponentType(){
return"javax.faces.HtmlInputText";
}
@Override
public String getRendererType(){
returnnull;// no standalone renderer
}
@Override
publicvoid release(){
super.release();
role =null;
}
public String getValue(){
return value;
}
publicvoid setValue(String value){
this.value = value;
}
public String getOnkeypress(){
return onkeypress;
}
publicvoid setOnkeypress(String onkeypress){
this.onkeypress = onkeypress;
}
public String getId(){
return id;
}
publicvoid setId(String id){
this.id = id;
}
}
and my tld definition:
<taglib>
<tlib-version>0.03</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>arvato-jsf</short-name>
<uri>http://arvato.com/jsf/component/tags</uri>
<description>Arvato JSF tags</description>
<tag>
<name>textfield</name>
<tag-class>com.arvato.jsf.tag.ArvatoTextFieldTag</tag-class>
<attribute>
<name>id</name>
</attribute>
<attribute>
<name>role</name>
</attribute>
<attribute>
<name>value</name>
</attribute>
<attribute>
<name>onkeypress</name>
</attribute>
</tag>
</taglib>

