This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The default NetBeans IDE allows to drag/drop JSF Form & Data Table. Dragging a JSF Form widget gives an option to generate an empty form or base it from an Entity class. Clicking the second option generates the following code: -- cut here -- <h:form> <h:panelGrid columns="2"> <h:outputText value="Id:"/> <h:outputText value="#{anInstanceOfserver.Cities.id}" title="Id" /> <h:outputText value="CityName:"/> <h:outputText value="#{anInstanceOfserver.Cities.cityName}" title="CityName" /> <h:outputText value="CountryName:"/> <h:outputText value="#{anInstanceOfserver.Cities.countryName}" title="CountryName" /> </h:panelGrid> </h:form> -- cut here -- #{anInstanceOfserver.Cities.id} gives a hint that server.Cities needs to be declared somewhere and then used. Instead make an entry in faces-config.xml and use that instead. Less work for developers.
If the entity bean is already defined in faces-config.xml, then that should be used instead.
To consist with the Managed Beans creating, looks like we will need to use 'capitalized' name for the managed-bean-name: <managed-bean> <managed-bean-name>Cities</managed-bean-name> <managed-bean-class>server.Cities</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> and then generate codes like: <h:outputText value="#{Cities.id}" title="Id" /> <h:outputText value="#{Cities.cityName}" title="CityName" /> <h:outputText value="#{Cities.countryName}" title="CountryName" />
I think we should not automatically insert new <managed-bean> definition here without asking users. I think we had better to add an UI in the drag-n-drop dialog asking which <managed-bean> they want to use for this new codes. Users can also use this UI to search exist <managed-bean> definition or just a new name for the IDE to automatically create it and use it.
The suggested approach sounds reasonable to me.
Implementation note: - in class org.netbeans.modules.web.jsf.palette.items.JsfFormCustomizer, add the following UI below entry "Entity Class:". <JRadioButton> Registered Managed Bean: <JComboBox> <JRadioButton> Create New Managed Bean: <JTextField> <JRadioButton> Do not use Managed Bean. - in method checkStatus, whenever it found a valid Entity Class, search the matched (same class) Managed Beans by calling org.netbeans.modules.web.jsf.editor.jspel.getBeans. Then list them in the JComboBox. If found, set the default to "Registered Managed Bean:" and select the first entry. - in method evaluateInput, call jsfTable.setVariable with the user input of Managed Bean. Create new Managed Bean entry by calling org.netbeans.modules.web.jsf.api.facesmodel.FacesConfig.addManagedBean when user check "Create New Managed Bean".
*** Issue 85594 has been marked as a duplicate of this issue. ***
It's implemented in 7.0 trunk. changeset 545efc178d35 in main details: http://hg.netbeans.org/main?cmd=changeset;node=545efc178d35
Integrated into 'main-golden', will be available in build *200812121401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/545efc178d35 User: potingwu@netbeans.org Log: Implement Issue#144217: Managed bean in faces-config.xml for DataTable Improve the UI and code generation for JSF Form and JSF Table; automatically setup a valid managed bean and use it in the JSP EL.