我正在实现Wicket IBehavior接口,并希望我的行为从onComponentTag方法更改组件的主体(或以某种方式更新模型)。 有没有办法做到这一点?Wicket:从IBehavior :: onComponentTag更改组件主体
@Override
public void onComponentTag(final Component component, final ComponentTag tag)
{
String myValue = tag.getAttribute("myAttribute");
// TODO: Based on the value of this attribute, update the body/model of the component
super.onComponentTag(component, tag);
}
编辑:我想抓住从指定的元件允许的最大字符数,如果需要,然后以编程截断元件的主体的HTML的属性。
例子:
<span wicket:id="myLabel" maxChars="10">The body of my tag</span>
将被替换成:
<span wicket:id="myLabel" maxChars="10">The bod...</span>
我想指定HTML中标签主体允许的最大字符数,然后获取该值并可能截断文本。 – Clayton 2010-10-18 22:54:41
我希望将这个功能封装在一个可应用于各种组件的行为中,但基于我的研究,我认为这是不可能的。 – Clayton 2010-10-19 16:33:48