Hi Oleg,
As advised, I am dropping my question here. We are doing a POC based on the Client's requirement using DynaForm to render Dynamic UI loading the configuration from Data Base.
Please refer this HTML code:
<pe:dynaFormControl type="input" for="txt" styleClass="dynaControl">
<p:inputText id="txt" value="#{data.value}" required="#{data.required}" maxlength="#{data.maxLength}" placeholder="#data.placeHolder}"/>
</pe:dynaFormControl>
The above code renders me the id as - mainForm:dynaForm:r1c1reg:txt
I know JSF generates the id and in dynaform based on the component order and type it's generating (mainForm:dynaForm:r1c1reg:). But after this prefix we have this txt. This txt is hard coded in the HTML. I would like to have my own id here populated from the model class. I am trying to configure the id or name attribute through the model class to avoid the rendering of - id="mainForm:dynaForm:r1c1reg:txt" name="mainForm:dynaForm:r1c1reg:txt". So, that we can do our java script stuff based on the id/name that we sent from the model class. I am trying something like this
<pe:dynaFormControl type="input" for="#{data.id}" styleClass="dynaControl">
<p:inputText id="#{data.id}" name="#{data.name}" value="#{data.value}" required="#{data.required}" maxlength="#data.maxLength}" placeholder="#{data.placeHolder}"/>
</pe:dynaFormControl>
Please look at the for, id and name attributes in the above code. But I end up with the following error:
Caused by: java.lang.IllegalArgumentException: Empty id attribute is not allowed
at javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:542)
at javax.faces.component.UIComponentBase.setId(UIComponentBase.java:369)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.assignUniqueId(ComponentTagHandlerDelegateImpl.java:369)
Is there a way to solve my problem statement? I would to like to have id/name defined for each of my control rendered through my model class. Let me know your thoughts.
Thanks in advance.
Dyna FOrm - Id or Name attribute population through model
Hello,
The question is not DynaForm related. And not PF Extensions related. In JSF you can not use EL expressions for ID. So, id=#{data.id} is not allowed in JSF. You can try to use c:set to overcome this issue and set dynamic IDs. I've blogged about this in my blog a couple of years ago. Take a look at last example http://ovaraksin.blogspot.de/2010/07/ou ... c-and.html I hope it will help you, but I'm not sure regarding data iteration components like DataTable, Tree, DynaForm because JSTL (e.g. c:set) is applied at an early JSF phase. In this early phase, the data iteration component didn't evaluate their childern yet. Simple try it.
The question is not DynaForm related. And not PF Extensions related. In JSF you can not use EL expressions for ID. So, id=#{data.id} is not allowed in JSF. You can try to use c:set to overcome this issue and set dynamic IDs. I've blogged about this in my blog a couple of years ago. Take a look at last example http://ovaraksin.blogspot.de/2010/07/ou ... c-and.html I hope it will help you, but I'm not sure regarding data iteration components like DataTable, Tree, DynaForm because JSTL (e.g. c:set) is applied at an early JSF phase. In this early phase, the data iteration component didn't evaluate their childern yet. Simple try it.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- Information
-
Who is online
Users browsing this forum: No registered users and 16 guests