tomahawk與trinidad提供了豐富的控件,但是當(dāng)默認(rèn)呈現(xiàn)器設(shè)置成org.apache.myfaces.trinidad.core時(shí),tomahawk中的dataScroll不能正常工作。如果不設(shè)置默認(rèn)呈現(xiàn)器,trinidad又不能工作,所以這是個(gè)矛盾,需要跟蹤代碼,使這兩個(gè)優(yōu)秀的開源JSF控件集能很好的共存。
解決方法:在eclipse中導(dǎo)入trinidad-1.0.2的源碼,修改包org.apache.myfaces.trinidadinternal.renderkit.htmlBasic中的HtmlCommandLinkRenderer.java。
public class HtmlCommandLinkRenderer extends Renderer
{
...
private Renderer renderer = null; //增加呈現(xiàn)器接口成員變量
....
//增加encodeBegin函數(shù)
@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函數(shù)為當(dāng)前代碼
@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);
}
...
}