0
我跟着this教程實現marquee標籤在JSF 2.1
併成功部分。由於這個標籤的確如此,不是支持動態數據,e.g. #{bean.var}
作爲一個值,我決定在組件內部弄髒它。JSF - 自定義標籤 - 動態值刷新後消失
但是,重新加載我的頁面後,該值消失。標籤仍然存在,但內容不見了。
- 你能告訴我如何實現是否正確,我可以在
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;
}
}
你的意思是使用'TextRenderer'而不是'UIComponentBase'? – JustBasti