This discussion is archived
4 Replies Latest reply: Jan 30, 2013 11:16 AM by Dave.Jarvis RSS

[SOLVED] Create ViewObject as placeholder for form parameters

Dave.Jarvis Newbie
Currently Being Moderated
Hi,

I have posted the following question (JDeveloper 11.1.2.3):

http://stackoverflow.com/questions/14592202/create-viewobject-as-placeholder-for-form-parameters

Essentially, how do you create a ViewObject that can perform validation, and leverage LOVs, but does not need to be backed by any data source?

Is this even the right approach?

Thank you!
  • 1. Re: Create ViewObject as placeholder for form parameters
    Timo Hahn Oracle ACE
    Currently Being Moderated
    Dave, Without looking into the stackoverflow thread I would create an entity object which is build on transient attributes only. From this eo you build a vo which you now can use in the UI like any other VO.
    To build such a EO you can create a EO of a real DB table, but remove all attributes which are really pointing to the db. Then you create new attributes using names and datatypes you need for your form.
    One thing to remember is that you have to create a row of the VO before going to the page. If you don't create such arow you can't input any data as there is no storage defined. This row will never written to the db as all attributes are transient.

    Timo
  • 2. Re: Create ViewObject as placeholder for form parameters
    Shay Shmeltzer Employee ACE
    Currently Being Moderated
    You don't need a VO - you can just expose a simple Java class with a method with parameters as a data control and create the page based on it.

    Similar to this: https://blogs.oracle.com/shay/entry/adding_lov_to_non_database
    More on java bean based data control - http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html
  • 3. Re: Create ViewObject as placeholder for form parameters
    Dave.Jarvis Newbie
    Currently Being Moderated
    The problem with using a Java class is that there is no simple way to use a List of Values with a ViewObject. It's possible, as shown in the video, but a bit more convoluted than I'd like.

    Edited by: Dave.Jarvis on Jan 30, 2013 9:25 AM
  • 4. Re: Create ViewObject as placeholder for form parameters
    Dave.Jarvis Newbie
    Currently Being Moderated
    Hi, Timo.

    This can be accomplished without an EO. As far as I can tell, this is the correct answer, but this forum will not allow me to select my own answer as correct, yet oddly does allow me to report my own post as abuse. Strange.

    Find the nicely formatted (and selected as correct) answer on StackOverflow: http://stackoverflow.com/a/14611815/59087

    # Solution

    You have to:

    - Create a view object to be programmatic, with the desired attributes.
    - Configure the view object with validation rules.
    - Configure the Application Module.
    - Create the web page form.
    - Update the page binding to create a new row.

    # Create View Object

    Create the view object as follows:

    1. Type <kbd>Control+n</kbd> to open the **New Gallery**.
    1. Search for and select **View Object**.
    1. Click **OK**.
    1. Set **Package**, **Name**, and **Display Name** appropriately.
    1. Set **Data Source** to **Programmatic**.
    1. Click **Next**.
    1. Click **New** and provide a meaningful attribute name.
    1. Click **OK**.
    1. Add the remaining attributes.
    1. Click **Next**.
    1. Set **Updatable** to **Always** for all attributes.
    1. Set **Type** to the appropriate data type.
    1. Click **Finish**.

    # Configure Validation Rules

    Configure the validation rules as follows:

    1. Click the **Attributes** finger tab.
    1. Select the desired attribute.
    1. Click the **Validation Rules** tab.
    1. Click the **+** icon within the **Validation Rules** section.
    1. Set the **Rule Definition** as required.
    1. Set the **Error Message** as required.
    1. Repeat to add as many validation rules as necessary.

    At this point a view object has been configured and the **List of Values** tab can be used to reference query-based LOVs.

    # Configure Application Module

    Configure the application module as follows:

    1. Double click the application's application module.
    1. Select the **Data Model** finger tab.
    1. Shuttle the view object from **Available View Objects** to **Data Model**.
    1. Remove the **1** suffix.
    1. Save the application.

    Note: If the view object is not visible, restart JDeveloper.

    # Create Web Page Form

    Create a web page for the form as follows:

    1. Create a new JSF page for the view object.
    1. Refresh the **Data Controls** to see the view object instance.
    1. Drag and drop the view object onto the page.
    1. Select **Form » ADF Form**.
    1. Check **Include Submit Button**.
    1. Click **OK**.

    The web page is created.

    # Update Page Binding

    The attributes for the view object cannot be changed unless there is a "row" created for the view object instance. Creating this in-memory row must happen before the page content is displayed. Accomplish this as follows:

    1. Expand the Data Controls to reveal the view object's **Operations**.
    1. Drag **Create** into the footer facet.
    1. Select **ADF Button**.
    1. Right-click on the page.
    1. Select **Go to Page Definition**.
    1. Click **+** beside **Executables**.
    1. Select **invokeAction**.
    1. Click **OK**.
    1. Set **id** to: create
    1. Set **Binds** to: Create
    1. Click OK.
    1. Set Refresh to: **prepareModel**
    1. Save all.

    You can now remove the "Create" button.

    Validation is applied and data-driven LOVs can be used.

    Edited by: Dave.Jarvis on Jan 30, 2013 11:15 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points