Weird new problem with dropDown control

View: New views
2 Messages — Rating Filter:   Alert me  

Weird new problem with dropDown control

by TedByers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I recently upgraded to NetBeans 6.1, and imported a project that started in NetBeans 6.0.

On one page in that project, I added, and initialized, a dropdown and found the following infrastructure was provided:

    private DropDown dropDown1 = new DropDown();

    public DropDown getDropDown1() {
        return dropDown1;
    }

    public void setDropDown1(DropDown dd) {
        this.dropDown1 = dd;
    }
    private LongConverter dropDown1Converter1 = new LongConverter();

    public LongConverter getDropDown1Converter1() {
        return dropDown1Converter1;
    }

    public void setDropDown1Converter1(LongConverter lc) {
        this.dropDown1Converter1 = lc;
    }

    private LongConverter dropDown1Converter = new LongConverter();

    public LongConverter getDropDown1Converter() {
        return dropDown1Converter;
    }

    public void setDropDown1Converter(LongConverter lc) {
        this.dropDown1Converter = lc;
    }

That appears to have been provided by NetBeans 6.0 as I didn't write any of this code myself.  Fortunately it all still works.

Now, in NetBeans 6.1, I need to add another dropdown control.  But NetBeans 6.1 is behaving differently.  The only infrastructure that is provided is:

    private SingleSelectOptionsList dropDown2DefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDown2DefaultOptions() {
        return dropDown2DefaultOptions;
    }

    public void setDropDown2DefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDown2DefaultOptions = ssol;
    }

It all compiles OK, and the control displays OK.  However, compare what I had to do in the change event handlers:

    public void dropDown1_processValueChange(ValueChangeEvent event) {
        this.getSessionBean1().setChart_type_id(8);
        Long p_id = (Long)this.getDropDown1().getValue();
        this.getSessionBean1().setPortfolio_id(p_id);
        this.image1.setUrl("/ChartMaker?pid=" + p_id + "&h=600&w=1200");
         getSessionBean1().setInPeriodSelectionComboboxChange(false);
    }

    public void dropDown2_processValueChange(ValueChangeEvent event) {
        getSessionBean1().setInPeriodSelectionComboboxChange(true);
        Long p_id = (Long)this.getDropDown2DefaultOptions().getSelectedValue();
        getSessionBean1().setPeriodSelected(p_id.intValue());
    }

This would be OK if it all worked properly.  It compiles OK, and dropDown1_processValueChange continues to work flawlessly.  However, "Long p_id = (Long)this.getDropDown2DefaultOptions().getSelectedValue();" does not work.  It ONLY returns null.  Obviously, the control is worthless if I can't get the value of the item that is selected.  In the java file for the page bean, there is no field called dropDown2 (although obviously there is one for dropDown1), although dropDown2 IS to be found (and it is correct) in the JSP file.

There are clear differences between NetBeans 6.0.1 and NetBeans 6.1, but I do not know if these are intended, and thus I do not know how to go about fixing this.  I REALLY don't want to replace the dropdown with a suite of command buttons (this would be feasible as there are only 5 items in the list, and there won't be more than 6 or 7).

Can someone please help me fix this?

Thanks

Ted

Re: Weird new problem with dropDown control

by Futaleufu_John :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In NetBeans 6.1 when you drop a component onto the design window an attribute for that component is no longer automatically created. To access the component in your backing bean, right-click the component and select Add Binding Attribute.

The reasoning for this is that we generally don't need to access most of the components in our backing bean, so all those extraneous attributes and getters/setters just add useless code.

It takes a little getting used to.
Any ads or links to ads that appear in this post are not endorsed nor recommended by this poster.