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.

Bug 144217 - Managed bean in faces-config.xml for DataTable
Summary: Managed bean in faces-config.xml for DataTable
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF (show other bugs)
Version: 6.x
Hardware: Macintosh All
: P3 blocker (vote)
Assignee: _ potingwu
URL:
Keywords:
: 85594 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-18 00:49 UTC by arungupta
Modified: 2009-02-19 23:26 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arungupta 2008-08-18 00:49:40 UTC
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.
Comment 1 arungupta 2008-08-19 20:42:54 UTC
If the entity bean is already defined in faces-config.xml, then that should be used instead.
Comment 2 _ potingwu 2008-08-29 18:27:53 UTC
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" />
Comment 3 _ potingwu 2008-09-02 20:45:56 UTC
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.
Comment 4 arungupta 2008-09-03 08:19:19 UTC
The suggested approach sounds reasonable to me.
Comment 5 _ potingwu 2008-09-03 20:20:46 UTC
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".
Comment 6 _ potingwu 2008-11-24 21:24:28 UTC
*** Issue 85594 has been marked as a duplicate of this issue. ***
Comment 7 _ potingwu 2008-12-12 17:01:03 UTC
It's implemented in 7.0 trunk.
    changeset 545efc178d35 in main
    details: http://hg.netbeans.org/main?cmd=changeset;node=545efc178d35
Comment 8 Quality Engineering 2008-12-12 17:32:02 UTC
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.