Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 8:13:02 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

July 2003
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Jun   Aug

Get Firefox!

Friday, July 25, 2003

"Why should I bother to call the edit() method in the supplied Struts EditAction?"

The edit() method in the oracle.jbo.html.struts11.EditAction (described more in detail in the BC4J Toy Store Whitepaper) is something you would call in your subclasses action before rendering the empty HTML input form for a user to fill in.

It creates a row, and then marks the row as having STATUS_INITIALIZED using the Row.setNewRowState(Row.STATUS_INITIALIZED) call.

By setting the row to STATUS_INITIALIZED, this makes BC4J "forget" that it's a new row that needs to be inserted. If you were to use this row again, just setting any of its attributes from the client would be enough to mark it again as STATUS_NEW and cause it to be inserted. In the Struts case, we actually just create the blank row to throw it away. It's only used for the purpose of rendering the blank form. An important reason you would want to do things this way is to pickup entity-level default values in the attributes of the new row.

For example, in the Toy Store Demo, why is it that when you register as a new user the "Country" poplist defaults to "United States" ? (Clue: it's not because it's the first entry in the list, which it isn't)

The answer is that, since the EditAction (or in this case my custom subclass of that) creates the blank row, the fact that the toystore.model.businessobjects.Account entity object declares that its Country attribute has a default value of "US" makes the blank row created in the toystore.model.dataaccess.Accounts view object have a default value of "US", and that default value in the blank row causes the <jbo:InputSelect> tag that renders the poplist to mark the corresponding "United States" option in the list as currently selected (as it's the display string associated in the poplist with the value "US").


12:01:25 PM    



© Copyright 2008 Steve Muench.