-
1. Re: missing JavaScript imports when programmatically including RichFaces components
daniell Dec 30, 2009 4:10 AM (in response to daniell)I already found a working solution in setting the LoadScriptStrategy and LoadStyleStrategy in the web.xml file to "ALL".
But why isn't it possible to load the scripts on demand? Are there any drawbacks in changing the strategies (except those mentionend in Chapter 5 of the Dev-Guide)?
-
2. Re: missing JavaScript imports when programmatically including RichFaces components
nbelaevski Dec 30, 2009 6:14 AM (in response to daniell)1 of 1 people found this helpfulHi,
This should work ok. Please post the code used for calendar inclusion.
-
3. Re: missing JavaScript imports when programmatically including RichFaces components
daniell Dec 30, 2009 6:52 AM (in response to nbelaevski)As suggested by several books and tutorials, I split up the JSF component code into three main classes.
In the component class (with the prefix UI) which extends UIInput, I create the instance of the RichFaces calendar using "new HtmlCalendar()" and keep it as private property.
I also set the datePattern and other configuration stuff in this component class.
private HtmlCalendar rfCalendar; public UIVisCalendar() { rfCalendar = new HtmlCalendar(); configureRfCalendar(); } private void configureRfCalendar() { rfCalendar.setConverter(getDateConverter()); rfCalendar.setDatePattern("dd.MM.yyyy"); rfCalendar.setImmediate(true); rfCalendar.setEnableManualInput(true); } public HtmlCalendar getRfCalendar() { return rfCalendar; }
In the renderer class (with the suffix Renderer) which extends AjaxComponentRendererBase, where I've access to my component class, there's some code to do additional (conditional) configuration stuff of the RF calendar. But basically I "draw" the RF calendar by calling the method encodeAll(context) in the Renderer's doEncodeBegin(...) method. The following snippet shows the important lines dealing with the RF calendar.
public void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { UIVisCalendar calendarVis = (UIVisCalendar) component; String clientId = component.getClientId(context); writer.startElement("div", null); // the RichFaces component for the date input calendarVis.getRfCalendar().setParent(component); calendarVis.getRfCalendar().setValue(calendarVis.getValue()); calendarVis.getRfCalendar().encodeAll(context); writer.endElement("div"); }
-
4. Re: missing JavaScript imports when programmatically including RichFaces components
nbelaevski Dec 30, 2009 9:04 AM (in response to daniell)You should add created calendar to component tree explicitly:
component.getChildren().add(calendar);
or
component.getFacets().put("calendar", calendar);
-
5. Re: missing JavaScript imports when programmatically including RichFaces components
daniell Jan 4, 2010 7:57 AM (in response to nbelaevski)Thank you! The things are getting clearer