Problem with ValueChange in dropdown

I'm having a problem with a valuechange for a dropdown I hope someone can help me solve.

I have a single page app used to track golfs scores and handicaps with the data stored in a MYSQL db. The user comes into the page, selects their name from a drop down list ( populated with a query to the GOLFERS table) and is then shown, in a table I named golfrounds_tb,their golf rounds with the course name, the tee, their raw and adjusted scores, plus the rating and slope of the course. The table is populated with a query to the GOLF_ROUNDS, COURSES and GOLFERS tables. As well, in a separate text field, their handicap is displayed.

The dropdown valuechange works fine to change the player data in the table but the only handicap ever shown is the very first one from the page prerender.

There are also other fields on the page which allows the user to add new rounds they've played. They can then press the 'Refresh Handicap' button to have their handicap recalculated, saved to the database and displayed in the Handicap text field. This also works fine

It's the drop down value change that I just can't seem to get to display the handicap of the golfers on subsequent changes to the drop down. The 'GOLFERS" table holds the handicap as well as the Golfer's name and GOLFERID. I've tried binding the HANDICAP text field to the same dataprovider that supplies the drop down. I've tried creating a separate query to the GOLFERS table using the golferid as the parameter. I've tried changing the text field to a static field and then tried both methods to populate the field on a dropdown change.

Here's the dropdown's valuechange.

public void golfers_dd_processValueChange(ValueChangeEvent event) {

try {

getSessionBean1().getGolf_roundsRowSet().setObject(

1, golfers_dd.getSelected());

getSessionBean1().getHandicapRowSet().setObject(

1, golfers_dd.getSelected());

golfersDataProvider.refresh();

golf_roundsDataProvider.refresh();

handicapDataProvider.refresh();

} catch (Exception e) {

error("Cannot switch to golfer " +

golfersDataProvider.getValue("GOLFERS.GOLFER_ID"));

log("Cannot switch to golfer " +

golfersDataProvider.getValue("GOLFERS.GOLFER_ID"), e);

}

}

the dropdown onchange is

common_timeoutSubmitForm(this.form, 'golfer_lp:golfers_dd');

I do have 2 layout panels but the handicap field is in the same one as the dropdown. The golfrounds table is not in a panel. But I've also tried removing the panel to no success.

What am I doing wrong?

[2627 byte] By [bonizaka] at [2007-11-27 0:03:56]
# 1

Hi There,

What is the sql where clause for the dataprovider bound to the textfield which displays the handicap? Are you passing the dropdownlists selected value to it properly.

Try this , rather than passing an object , is there a way to get the value as string or int and then pass it to the where clause?

Im sure you have already seen this

http://developers.sun.com/jscreator/learning/tutorials/2/databoundcomponents.ht ml

Thanks

K

kish@suna at 2007-7-11 15:58:25 > top of Java-index,Development Tools,Java Tools...
# 2

Thanks for the reply. I should have updated this thread when I fixed the problem. I set a session field and put the handicapRowSet in its own try/catch block. This works fine now.

public void golfers_dd_processValueChange(ValueChangeEvent event) {

try {

setValue("#{sessionScope.golferid}", golfers_dd.getSelected());

getSessionBean1().getGolf_roundsRowSet().setObject(

1, getValue("#{sessionScope.golferid}"));

golf_roundsDataProvider.refresh();

} catch (Exception e) {

error("Error with golfers_dd_processValueChange() " + e);

log("Error with golfers_dd_processValueChange() " + e);

}

try {

getSessionBean1().getHandicapRowSet().setObject(

1, getValue("#{sessionScope.golferid}"));

handicapDataProvider.refresh();

setValue("#{sessionScope.handicap_i}", handicapDataProvider.getValue("Golfers.Handicap"));

handicap_tf.setText(getValue("#{sessionScope.handicap_i}").toString());

} catch (Exception e) {

log("Error in golfers_dd_processValueChange():getHandicapRowSet: " + e);

error("Error in golfers_dd_processValueChange():getHandicapRowSet: " + e);

}

bonizaka at 2007-7-11 15:58:25 > top of Java-index,Development Tools,Java Tools...