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:12:22 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

May 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
Apr   Jun

Get Firefox!

Thursday, May 01, 2003

Sung Im, architect of the BC4J framework and a fellow team member, started a weblog today.
11:59:41 PM    



"How does the BC4J Toy Store Demo's UpdateAccountAction know which row to update?"

The "/editaccount" action mapping is engaged when the user clicks on the button to edit their account. The EditAccountAction extends the framework extension class ToyStoreEditAction (which in turn, extends the BC4J-supplied EditAction in the oracle.jbo.html.struts11.action package). The ToyStoreEditAction contains a method foundExistingRowWithKey() which looks up an existing row in the "chosen" view object, based on a Key value. The "chosen" view object is indicated declaratively in the struts-config.xml file entry for the "/editaccount" action mapping. The code of the foundExistingRowWithKey() method, uses the ViewObject's findByKey() function to find the existing row, and then it calls the setRow() and setRowkey() methods on the BC4JContext to set the current row. The current row in the BC4JContext is used to populate the Struts form bean upon which the Edit Account HTML Form will be based. The EditAccountAction simply constructs a Key to use for looking up the current row based on the value of the signed-in user's username, then called the foundExistingRowWithKey() method in its superclass to look it up. That handles getting the existing information onto the HTML Form to be edited. Notice that the Struts DynaActionForm named Accounts in struts-config.xml has a jboRowKey property and that the editexistingaccounts.jsp page has an <html:hidden property="jboRowKey"/> tag in the form.When the BC4J EditAction super class populates the form bean, it includes the row key for the current row in the BC4JContext in the form bean property named jboRowKey, and that tag makes sure that the property exists as a hidden field in the form to be sent back along with the other data when the form is posted.

When the users submits the form, it posts to the "/updateaccount" action. The UpdateAccountAction extends the ToystoreUpdateAction which extends the default BC4J-supplied UpdateAction. The base UpdateAction does the bulk of the work. The ToystoreUpdateAction superclass overrides how validation errors are translated into Struts Errors in a generic way. The UpdateAccountAction just calls the superclass, and commits if there were no errors. The BC4JContext class, when it gets initialized by the BC4JRequestProcessor, notices the jboRowKey parameter among the input parameters being submitted, and it sets the BC4JContext's row key. When the UpdateAction later calls the getRow() on the BC4JContext to retrieve the row, this row key is used in a call to JboUtil.getRowFromKey() to retrieve the row to be updated. Lastly, the UpdateAction uses the form bean created by Struts in reaction to the form submit to populate the updated values from the form in this existing row.


12:11:32 AM    


© Copyright 2008 Steve Muench.