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);
}
...
}