refresh text fields values

Hi,

On a page I have some text fields which are to bound data fields of a dataprovider using bind to data menu option.

Dataprovider is refreshed in prerender method. Values of text fields are correct on first time but second time when page is displayed the text feilds shows old data i.e. stale data. However static text's text is updated everytime.Any suggestions?

Thanks.

[399 byte] By [ndzpac] at [2007-11-26 9:43:44]
# 1

There may be a conversion, validation, class casting, NPE error that is causing the app to revert to the previous page's values.

Do you have a message group on the page? If not, add one to the page and see if any runtime errors appear. Also, right-click Deployment Server in the Servers window and choose View Server Log from the pop-up menu. When you run the app, look at the output in the log to see if any errors appear.

jetsons at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 2
Thanks for the feedback jetsons.I do have message group on the page and I have also checked the server log. I can't see any error. But if there was any error then I guess static text's text won't get updated.
ndzpac at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 3

Yes, you are correct. (like duh! Oh well , it IS Friday and the end of a long week ;^)

The only time I have seen this happen (text field bound to a data provider not updated) is when I had the text field set to read only. I reported that bug and the fix just happens to be in today's hot fix release.

This might also happen if you have input fields in a table and you don't have your virtual forms set up correctly (like in http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/ins erts_updates_deletes.html)

A third reason might be if the data provider is wrapping an array or list. I seem to recall some info floating around about this scenario. What type of data provider are you using?

Is this the only page you have built with text fields bound to a data provider? If not, do you always have this problem?

jetsons at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 4
No, I am not using table and neither they are set read only.Data provider just returns one record.Only one thing to mention as I see that:CachedRowSetDataProvider and CachedRowSet are both present in page i.e. CachedRowSet is not in session as mostly the case in
ndzpac at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 5
It is fixed by changing javax.faces.STATE_SAVING_METHOD value from server to client.
ndzpac at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 6

I have the same problem. Only I have created a portlet. A dropwdown list and 3 textfields.

The text fields are supposed to be changed after selecting a different value on the dropdown list. This dosent happen.

But it seems to go correct coz I pull out the value directly from the

xxdataprovider.getvalue("ttt");

It prints out different values after changing the dropdown list. But not the text fields.

Where did you change this javax.faces.STATE_SAVING_METHOD value to client ?

cram11 at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 7
you can change that in web.xml file <context-param><param-name>javax.faces.STATE_SAVING_METHOD</param-name><param-value>client</param-value> </context-param>
ndzpac at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 8
Thanks.But that didnt help me. Still got the same problem.Any more ideas?
cram11 at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 9
Can't think of anything else and I don't have any idea of portlet. May be just make sure that you have followed the above mentioned jetsons's guidelines.
ndzpac at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 10

> The text fields are supposed to be changed after selecting a different value on > the dropdown list. This dosent happen.

Try this

1. Put the drop down list in a virtual form (let's call it master). Set both Participate and Submit to Yes

2. Put the text fields in a different virtual form (let's call it detail). Set Participate to Yes and Submit to no.

3. In the process value change method for the drop down list, add the following:

form1.discardSubmittedValues("detail");

jetsons at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 11

Thanks! I already got it to work.

Found out that with portlets we have to treat a bit different. I had to save the dropdown value to the session bean to make the other fields to be updated with the selected value from dropdown field.

But got into a different problem.

The dropdown value is binded to a different table than the other fields I am updating. Now I want also to update a field that is not binded, but is in the same table as the dropdown value.

table1 - contains the dropdown value that is binded, and another field value that I dont bind.

table2 - contains the fields I refresh and able to update.

With the code:

table1DataProvider.setValue("Colname"; "text value");

table1DataProvider.commitChanges(); -> don't work

table2DataProvider.commitChanges(); -> works

On web I can see the changes and that the value has changed. But this is not saved in the database.

What am I doing wrong?

cram11 at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 12

> With the code:

> table1DataProvider.setValue("Colname"; "text

> value");

> table1DataProvider.commitChanges(); -> don't work

> table2DataProvider.commitChanges(); -> works

>

> On web I can see the changes and that the value has

> changed. But this is not saved in the database.

>

> What am I doing wrong?

In your query for the underlying rowset for table1DataProvider, are you including the "Colname" column (what ever column you are setting the value for)?

jetsons at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...
# 13
Got this to work now. It was my datatype that was causing the problem. Once I changed that, everything worked fine.Thanks!
cram11 at 2007-7-7 0:44:57 > top of Java-index,Development Tools,Java Tools...