Problem with Saving Data Changes to Oracle Table
Problem with Saving Data Changes to Oracle Table
- Subject: Problem with Saving Data Changes to Oracle Table
- From: email@hidden
- Date: Sun, 18 Jul 2004 15:49:20 EDT
I am new to WebObjects and web development.
I have a WebObjects application that contains URLs that go to webpages not in
my application. These links are contained in an Oracle table and when the
application is loaded a NSArray is created with these links. This NSArray is
then bound to a WORepetition. I have a WOHyperlink within the WORepetition
and
the action is bound to some code (see below).
What I am trying to do is count the number of times these URLs are clicked.
The problem I am having is that the updated count is not being saved to the
Oracle table after the application is closed. While I am in the application
and clicking these links I can see that the correct count is being retrieved
and
updated via the ProjectBuilder Launch screen. I have a series of
system.out.println statements that allow me to follow what is happening.
After I close
the application and launch again, the count is back to the original number.
It
is not saving the updated value when I close the application. Most likely it
is not saving the value to the table while I am in the application even
though it appears to be when I click the url multiple times and see the value
update.
The code compiles and runs fine except for the save. I am directed to the
correct webpage via the link returned from the code.
What am I a missing in the code? Is there something else that needs to be
done in the Application.java file to have these updates happen?
Any help you can provide will be greatly appreciated.
Thanksb&b&b&Sandy
Code WOHyperlink action bound to:
Note: ec is defined in the java file where this code resides.
Public WOComponent countHitsOnUrl(){
WOComponent urlListing = pageWithName("WORedirect");
Number hitCount = url.urlHits();
Int hitCount2 = hitCount.intValue() + 1;
Number hitCount3 = (Number) hitCount2;
url.setUrlHits(HitCount3);
ec.saveChanges();
urlListing.takeValueForKey(url.ValueForKey("url"),"url");
return urlListing;
}
The code below is in the class file for the Oracle table:
Public void setUrlHits(Number value) {
takeStoredValueForKey(value, "urlHits");}
public number urlHits() {
return (Number) storedValueForKey("urlHits");}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.