-
1. <rich:toolbar> and binding
nbelaevski Feb 16, 2011 6:13 PM (in response to vrelits)Hi Jesper,
I guess you are creating components incorrectly. You shoudl be using application.createComponent(FacesContext, String, String) and not 'new ComponentClass()'.
-
2. <rich:toolbar> and binding
vrelits Feb 17, 2011 1:50 AM (in response to nbelaevski)Hi Nick!
Actually I use application.createComponent. Here's a code snippet:
if (dropDownMenu == null) {
dropDownMenu = (UIDropDownMenu) app.createComponent(UIDropDownMenu.COMPONENT_TYPE);
dropDownMenu.setHideDelay(0);
HtmlOutputText label = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
label.setValue(menu.getName());
dropDownMenu.getFacets().put(UIDropDownMenu.Facets.label.name(), label);
dropDownMenu.setMode(null);
newToolBar.getChildren().add(dropDownMenu);
}
where 'app' is FacesContext.getCurrentInstance().getApplication();
I've ported the code from Richfaces 3.3 where I didn't have this issue.
-
3. <rich:toolbar> and binding
nbelaevski Feb 17, 2011 7:34 AM (in response to vrelits) -
4. <rich:toolbar> and binding
vrelits Mar 15, 2011 9:36 AM (in response to nbelaevski)The javadoc for JSF 2.0 rev A says this:
"... Instantiate and return a new UIComponent instance of the class specified by a previous call to addComponent() for the specified component type.
Before the component instance is returned, it must be inspected for the presence of a ListenerFor (or ListenersFor) or ResourceDependency (or ResourceDependencies) annotation. If any of these annotations are present, the action listed in ListenerFor or ResourceDependency must be taken on the component, before it is returned from this method. This variant of createComponent must not inspect the Renderer for the component to be returned for any of the afore mentioned annotations. Such inspection is the province of createComponent(ValueExpression, FacesContext, String, String) or createComponent(FacesContext, String, String). ...."
This is what MyFaces does, and we can't change it. Any change should be done at spec level. It is known this problem prevent JSF 2.0 resource API to work correctly on jsp case.
WHAT DOES THIS MEAN? ANY HOPE FOR RESOLUTION?
-
5. <rich:toolbar> and binding
nbelaevski Mar 15, 2011 9:45 AM (in response to vrelits)This means that you should specify both component type and renderer type when you call createComponent. In this case it will work as expected.
-
6. <rich:toolbar> and binding
vrelits Mar 15, 2011 10:23 AM (in response to nbelaevski)Okay, tried this:
if (toolBar == null) {
FacesContext ctx = FacesContext.getCurrentInstance();
UIToolbar newToolBar = (UIToolbar) ctx.getApplication()
.createComponent(ctx, UIToolbar.COMPONENT_TYPE, "org.richfaces.renderkit.html.ToolbarRenderer");
for (Module module : portal.getModules()) {
addModuleMenus(ctx.getApplication(), newToolBar, module);
}
// If user is authorized to no modules, add empty dropdown to get the menubar drawn.
if (newToolBar.getChildren().size() == 0) {
UIDropDownMenu dropDownMenu = (UIDropDownMenu) ctx.getApplication().createComponent(ctx,UIDropDownMenu.COMPONENT_TYPE,
"org.richfaces.renderkit.html.DropDownMenuRenderer");
dropDownMenu.setHideDelay(0);
dropDownMenu.setMode(Mode.ajax);
newToolBar.getChildren().add(dropDownMenu);
}
toolBar = newToolBar;
}
but it didn't do any different. Do I call createComponent wrongly?
-
7. <rich:toolbar> and binding
vrelits Mar 18, 2011 4:47 AM (in response to vrelits)A small bump here. Is this supposed to be able to work? I can see others have problems with bindings too.
I know you guys are busy with the forthcomming release but a small code example how to create a dropdown menu code and display it using the binding variable would be very appreciated.
We'are converting a RF 3 project and this is really a showstopper.
Running on Mojarra 2.1.0-b11
-
8. <rich:toolbar> and binding
ilya_shaikovsky Mar 18, 2011 6:08 AM (in response to vrelits)Sorry for the delay :/ Plates are really full during that time Seems I get the problem source now. Actually it's just JSF 2 problem which I believe should be solved at some point by the Oracle and Apache guys. Dynamicall rendering of the components (which was at component tree before but just not rendered) works fine in JSF as it pre-renders resources for all the components even for those which are not rendered. But that is not applied to the case when the component was not present in JSF tree at all. And unfortunatelly it's your case. And the only workaround we found:
add <dropDownMenu rendered="false"/> to the page.
-
9. <rich:toolbar> and binding
vrelits Mar 18, 2011 6:44 AM (in response to ilya_shaikovsky)Got it working, but I had to add all component types toolbar, dropDownMenu, MenuGroup and menuItem with rendered="false".
Thanks for the hint.