How to update a bound textField with user selection ?

Hi all,

I'm following an Update Database example from the JSC tutorials and have the following situation.

I have a page displaying a row of data for a selected person (first_name, last_name, title) bound to a data provider. I have made the "title' field a TextField. I want to enable the user to edit the title field and update the information in the database.

If I simply type a new title on the text field and click on Update, everything works fine. However, I want to make the user choose from a list of titles (in a drop down list) instead of manually editting the 'title

field to avoid spelling errors.

However, the textfield (title) does not display the selection from the Drop Down list.

titleField.setText(rankdropDown.getSelected());

It seems to me that the reason is that each time the drop down event value change event handler is executed, the Pre-render methd kicks in and restores the 'title' field to its original value (from table rowset). And the user selection is not displayed.

public void prerender() {

try {

getSessionBean1().getStudent_infoRowSet1().setObject(1, getSessionBean1().getLoginBean().getUsername());

student_infoDataProvider1.refresh();

} catch (Exception e) {

Can someone please suggest a solution?

Thanks.

Nakul

[1352 byte] By [nakulnayyar] at [2007-11-26 11:36:50]
# 1

Are you submitting the page after selecting the data from the drop down?

The drop down does not seem to have an option of submiting the page when the value is changed. Only if you submit the page, will the data be processed and the text field updated.

From what i see in the doc for the prerender method, this method is invoked during the renderResponse phase. Whereas the value change event is processed during the process validation phase itself of the jsf life cycle.

deepsix at 2007-7-7 11:35:03 > top of Java-index,Development Tools,Java Tools...
# 2
Thanks for the response. I solved it by simply bounding the column of data to a table comprising of input options.
nakulnayyar at 2007-7-7 11:35:03 > top of Java-index,Development Tools,Java Tools...