JavaScript フレームワーク (Ideal Forms という名前) を JSF と共に使用したいと考えています。data-ideal
このフレームワークは、JSF にとって未知のいくつかの特別な属性 (" " など) を使用します。これらの属性は、JSF のレンダリング プロセスによって削除されます。
BalusCのコード スニペット(stackoverflow から) に基づいて、これらの属性を JSF コンポーネントにチートしようとしました。
public class PreRenderViewListener implements SystemEventListener {
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
UIViewRoot root = (UIViewRoot) event.getSource();
UIComponent comp = root.findComponent("myForm:myField");
comp.getAttributes().put("style", "width: 100px;");
comp.getAttributes().put("data-ideal", "some_content");
}
...
xhtmlコードは
<h:form id="myForm">
<h:inputText id="myField" ... />
</h:form>
結果は
<form id="myForm" name="myForm" ... >
<input id="myForm:myField" type="text" name="myForm:myField" style="width: 100px;" />
</form>
ご覧のとおり、最初の属性style
(h:inputText に認識されている) はクライアントにレンダリングされますが、2 番目の属性data-ideal
(JSF にまったく認識されていない) はレンダリングされません。カスタム コンポーネントを作成せずに jsf-foreign 属性をサポートする方法について何か提案はありますか? どうもありがとうございました。