Sunday, May 18, 2008

LOV in Create Form with Mandatory Fields

One more reason why Oracle Rocks Again - JDeveloper 11g TP4, its a solved issue with LOV fields in Create form that contains mandatory fields. I have documented this issue some time ago on OTN. Also I have described it in my previous post with sample application - Hints for List-Of-Values (LOV) in JDeveloper 11g TP3. The main problem was, that it was impossible to use LOV in Create form with even one or several not associated mandatory fields - validation errors were shown when value was selected in LOV window. Actually, similar problem was in JDeveloper 10.1.3.x also, but now it is solved. In this post I will describe how it works now.

You can download sample application I have developed - LOV11Create.zip. This application contains two fragments, one is used for Search and Edit forms and second for Create form. Fragments are implemented in Task Flow, which is dropped to JSPX page as Region. I have developed Create form for Employees entity and have defined two LOV components - one for JobId and second for DepartmentId attributes.

In 10.1.3.x to develop Create form, you was using invokeAction in Page Definition. However, it is changed now. In 11g you need to use Method Call activity in your Task Flow to invoke Create mode and pass navigation to a form - it's a key point now. In diagram below, create navigation rule points to invokeCreate Method Call activity. This activity executes Create action associated with your Data Control and pass navigation to a form that will be displayed in Create mode:


Don't forget to set SkipValidation = true property in Page Definition file created for invokeCreate Method Call activity. This will allow to open our form with mandatory fields in Create mode.

In Property Inspector you can see that invokeCreate activity invokes #{bindings.Create.execute} action, exactly what we want:


On runtime, when form is opened in Create mode, we can use LOV component now:


Provide values for other not associated fields contained in the form:


And save entered record to the database:

12 comments:

Anonymous said...

Hi Andre

Why did you use a method call with #{bindings.Create.execute}?

In your CRUD example you create the new row of the view object by adding the create method to the binding of the create pagefragment.
This looks more simple to me. Is there a difference or are these just two ways to reach the same goal?

Regards

Robert

Andrej Baranovskij said...

Hi Robert,

Its because in this example I'm using LOV in Create form. In order to make LOV component work in Create form with mandatory fields, we need to use method call with #{bindings.Create.execute}.

Regards,
Andrejus

Anonymous said...

Hello, I have a question that has nothing to do with this article. I'm wondering how can i catch keyboard events en al web application using adf faces. I don't know if it is a specific panel i have to use, i can't find a way to implement it. I know java, but i am very new to ADF Faces. Thanks in advance,
Viviana

Andrej Baranovskij said...

Viviana,

You can take a look into 'Getting the keycode of the pressed key' section available in Frank Nimphius blog ADF Faces Rich Client - JavaScript Programming Nuggets.

Regards,
Andrejus

Anonymous said...

Hi Andre,

Thanks for the beautiful solution. I am facing another problem after incorporating the solution suggested by you. If I click the submit button before entering any values in create form,I get validation errors (like for mandatory fields) as expected. Now if i open the LOV popup and double click on any of the rows or say ok, no value gets selected. Have you faced this error?

regards
sameer

Andrej Baranovskij said...

Hi,

Yes, its ADF bug. They should fix in Patch release.

Regards,
Andrejus

Anonymous said...

Thanks Andre for the confirmation.

I am facing another problem.
I tried calling the bindings.create method as the default activity in my taskflow. The row might be created but its not seen on the createForm and data from the first row of bounded iterator(EmployeesView1Iterator) is shown. This is because the iterator binding also resides in the create form pageDef and it gets refereshed. How to handle this?
Using createInsert solves this problem but it will be a bad design because user might never submit the form, leaving empty rows in the Iterator.

Another problem is of refereshing the create form as I need to land back on create form after page submission. As there is no invoke action for create, the page will still contain the old row.
So how to referesh the page with new row after successful submission of data?

Regards
sameer

Andrej Baranovskij said...

Hi,

Possible solution for your issue can be to base Create method call in Task Flow on the same Page Definition assigned for page.

You can read my post, where I'm putting Find method call to Page Definition assigned for page - Form Opening in Find Mode.

Regards,
Andrejus

Anonymous said...

Hi Andre,

But this again means that the original problem of mandatory fields violations will resurface.

regards
sameer

Andrej Baranovskij said...

No, it will not. Just set SkipValdation=true on your Page Def.

Regards,
Andrejus

Anonymous said...

Hi Andrejus

I find your blog very useful - thank you.

I have a related query.

I have a task flow with a create method which calls a page containing the create form. The create form opens with an empty row as expected (no messages about missing mandatory fields).

To allow the user to input a whole bunch of records, in the task flow I return to the create method (and call this action on successful commit) so that the form is populated with another blank record ready for the user's input.

However, when I add a table to the same page (below the form), then I _do_ get the messages about the missing mandatory fields in the form when the page opens. (I have checked and I have SkipValidation="true" for the method-call's pagedef file.) The table is intended to show the records as they are being added. It is based on a read-only view.

What causes this and is there anything I can do about it?

thanks
Lisa

Andrej Baranovskij said...

Hi Lisa,

I suggest to put this table into region.

Regards,
Andrejus