-
1. RichFaces 4: how to create components dynamically (h:head injection)?
ilya_shaikovsky Apr 22, 2011 5:58 AM (in response to kennardconsulting)That's actually caused by JSF 2 originally. In order resources to be added properly during programmatic addition of the component - you shoould use
Application.createComponent(FacesContext context,
String componentType,
String rendererType)
call to create the component..if you will just create component instance using new or with api which passd only with the component type param - resources required by the component will not be checked.
-
2. RichFaces 4: how to create components dynamically (h:head injection)?
nbelaevski Apr 22, 2011 6:46 AM (in response to ilya_shaikovsky)Hi Richard,
One more thing - JSF does not allow resources to be added by Ajax, so you have to have calendar on the page that is initially loaded.
-
3. RichFaces 4: how to create components dynamically (h:head injection)?
kennardconsulting Apr 22, 2011 6:16 PM (in response to nbelaevski)Hi Ilya, Nick,
Thanks for the fast response!
Your suggestion appears to work great under MyFaces 2, but Mojarra 2 is still displaying the same incorrect behaviour.
Could this be related to the fact that under Mojarra I have set 'javax.faces.PARTIAL_STATE_SAVING' to 'false', which I need to do for other reasons (http://java.net/jira/browse/JAVASERVERFACES-1826)?
Regards,
Richard.
-
4. RichFaces 4: how to create components dynamically (h:head injection)?
kennardconsulting Apr 25, 2011 1:33 AM (in response to kennardconsulting)Ilya, Nick,
A follow up:
1. Yes, PARTIAL_STATE_SAVING=false does seem to cause problems (I tried it on MyFaces, and it has the same issue). Can I do something about that?
2. The injected resources do not appear to survive POSTback? For example if I have a UICalendar on my form, and I get some validation error when I hit submit, the UICalendar on the redisplayed form does not work. Equally if I dynamically generate a TabPanel and then POSTback, all of the JavaScript/CSS for the TabPanel is lost upon redisplay. Is there something else I need to do to cater for POSTback?
Regards,
Richard.
-
5. RichFaces 4: how to create components dynamically (h:head injection)?
kennardconsulting Apr 25, 2011 7:12 AM (in response to kennardconsulting)Created a small test app and opened a JIRA: https://issues.jboss.org/browse/RF-10951
Thanks,
Richard.
-
6. RichFaces 4: how to create components dynamically (h:head injection)?
nbelaevski Apr 25, 2011 7:14 AM (in response to kennardconsulting)Richard,
1. Yes, PARTIAL_STATE_SAVING=false does seem to cause problems (I tried it on MyFaces, and it has the same issue). Can I do something about that?
I cannot suggest something for now, need to investigate.
2. The injected resources do not appear to survive POSTback? For example if I have a UICalendar on my form, and I get some validation error when I hit submit, the UICalendar on the redisplayed form does not work. Equally if I dynamically generate a TabPanel and then POSTback, all of the JavaScript/CSS for the TabPanel is lost upon redisplay. Is there something else I need to do to cater for POSTback?
I observed this issue in Mojarra 2.0.2, but 2.0.3+ fixed that.
How do you generate components BTW, in action method or using some other way?
-
7. RichFaces 4: how to create components dynamically (h:head injection)?
nbelaevski Apr 25, 2011 7:15 AM (in response to kennardconsulting)Thanks, we'll take a look at the JIRA.
-
8. Re: RichFaces 4: how to create components dynamically (h:head injection)?
piyush.mnnit Jun 18, 2013 1:57 AM (in response to ilya_shaikovsky)Hi llya,
I tried to call Application.createComponent even then required JS and CSS files are being loaded. please find the code below:
ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application app = factory.getApplication();
FacesContext ctx = FacesContext.getCurrentInstance();
UICalendar calendar = (UICalendar)app.createComponent(ctx, UICalendar.COMPONENT_TYPE, "org.richfaces.CalendarRenderer");
calendar.setPopup(true);
Please let me know if I have done any mistake or there is other alternative.
Regards,
Piyush Jain
-
9. Re: RichFaces 4: how to create components dynamically (h:head injection)?
bleathem Jun 18, 2013 1:42 PM (in response to piyush.mnnit)Piyush Jain asked his question in a new thread. Look there for a continuation of this discussion: