【发布时间】:2014-03-23 18:40:09
【问题描述】:
我已按照 this 教程在JSF 2.1 中实现选取框标签并部分成功。由于这个标签 NOT 支持动态数据,e.g. #{bean.var} 作为一个值,我决定在组件内部做脏。
但是,重新加载我的页面后,该值消失了。标签还在,但内容不见了。
- 能否告诉我如何正确实施,我可以在
value-attribute中使用我的动态值? - 或者您能否指出正确的方向是哪个代码导致了我的
component class中的错误?
非常感谢!
http://myjavabuddy.blogspot.de/2013/04/writing-custom-components-for-jsf-20.html
这是我的 JSF
<customJSF:marquee value="" />
这是我的组件
@FacesComponent ("amelunxenfast.prog3.wissensmanagement.components.marquee")
public class MarqueeComponent extends UIComponentBase {
public static final String COMPONENT_TYPE = "com.himanshu.jsf.custom.marquee";
String value = null;
@EJB
FeedEJB ejb;
public String getValue() {
return value;
}
@Override
public String getFamily() {
return COMPONENT_TYPE;
}
@Override
public void encodeBegin(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.startElement("marquee", this);
writer.writeAttribute("scrollamount", "10", "");
writer.write(ejb.getFeedString());
writer.endElement("marquee");
}
@Override
public void encodeEnd(FacesContext arg0) throws IOException {
super.encodeEnd(arg0);
}
public void setValue(String value) {
this.value = value;
}
}
【问题讨论】: