tomahawk与trinidad提供了丰富的控件,但是当默认呈现器设置成org.apache.myfaces.trinidad.core时,tomahawk中的dataScroll不能正常工作。如果不设置默认呈现器,trinidad又不能工作,所以这是个矛盾,需要跟踪代码,使这两个优秀的开源JSF控件集能很好的共存。
解决方法:在eclipse中导入trinidad-1.0.2的源码,修改包org.apache.myfaces.trinidadinternal.renderkit.htmlBasic中的HtmlCommandLinkRenderer.java。
public class HtmlCommandLinkRenderer extends Renderer
{
...
private Renderer renderer = null; //增加呈现器接口成员变量
....
//增加encodeBegin函数
@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext context,
UIComponent component) throws IOException
{
// The tr:commandLink is not a rendersChildren component,
// but h:commandLink is. Hence, the difference in behavior
renderer = createRenderer(component);
renderer.encodeBegin(context, component);
for(UIComponent child : (List<UIComponent>)component.getChildren())
{
RenderUtils.encodeRecursive(context, child);
}
}
...
//修改encodeEnd函数为当前代码
@SuppressWarnings("unchecked")
@Override
public void encodeEnd(FacesContext context,
UIComponent component) throws IOException
{
// The tr:commandLink is not a rendersChildren component,
// but h:commandLink is. Hence, the difference in behavior
if(renderer==null)
{
renderer = createRenderer(component);
renderer.encodeBegin(context, component);
for(UIComponent child : (List<UIComponent>)component.getChildren())
{
RenderUtils.encodeRecursive(context, child);
}
}
renderer.encodeEnd(context, component);
}
...
}