Domanda

I'm starting with Oracle ADF and JDeveloper. I'm doing some basic tutorials first.

From the HR database schema, I'm trying this exercise: create a new location, but in CountryId attribute, show all countries list.

This is more user-friendly, so the user can select Italy instead of typing IT .

For this, I'm doing this steps:

In Locations view , choose CountryId attribute and create a LOV. This one must read from CountriesView1, with value CountryId attribute, and show CountryName attribute.

  1. Drop LocationsView1 in a page and select ADF Form.
  2. Select CountryId as a combo box.
  3. Drop Create operation from LocationsView1 as a button.
  4. Drop Commit operation as a button.

When running this page, I see all country names, but when I choose one of them, it does not show me it as selected, and, when commit the new data, CountryId is inserting with null value.

Obviously, I'm doing something in a wrong way. How can I do this simple form, with CountryId as a list?

Can anyone help me, please?

Thanks in advance. Best regards

EDIT: code of dataEntry.jspx

    <?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_dataEntry.d1}">
      <af:messages binding="#{backingBeanScope.backing_dataEntry.m1}" id="m1"/>
      <af:form id="f1" binding="#{backingBeanScope.backing_dataEntry.f1}">
        <af:panelStretchLayout id="psl1"
                               binding="#{backingBeanScope.backing_dataEntry.psl1}">
          <f:facet name="center">
            <af:panelFormLayout binding="#{backingBeanScope.backing_dataEntry.pfl1}"
                                id="pfl1">
              <af:panelFormLayout binding="#{backingBeanScope.backing_dataEntry.pfl2}"
                                  id="pfl2">
                <af:inputText value="#{bindings.LocationId.inputValue}"
                              label="#{bindings.LocationId.hints.label}"
                              required="#{bindings.LocationId.hints.mandatory}"
                              columns="#{bindings.LocationId.hints.displayWidth}"
                              maximumLength="#{bindings.LocationId.hints.precision}"
                              shortDesc="#{bindings.LocationId.hints.tooltip}"
                              binding="#{backingBeanScope.backing_dataEntry.it1}"
                              id="it1">
                  <f:validator binding="#{bindings.LocationId.validator}"/>
                  <af:convertNumber groupingUsed="false"
                                    pattern="#{bindings.LocationId.format}"/>
                </af:inputText>
                <af:inputText value="#{bindings.StreetAddress.inputValue}"
                              label="#{bindings.StreetAddress.hints.label}"
                              required="#{bindings.StreetAddress.hints.mandatory}"
                              columns="#{bindings.StreetAddress.hints.displayWidth}"
                              maximumLength="#{bindings.StreetAddress.hints.precision}"
                              shortDesc="#{bindings.StreetAddress.hints.tooltip}"
                              binding="#{backingBeanScope.backing_dataEntry.it2}"
                              id="it2">
                  <f:validator binding="#{bindings.StreetAddress.validator}"/>
                </af:inputText>
                <af:inputText value="#{bindings.PostalCode.inputValue}"
                              label="#{bindings.PostalCode.hints.label}"
                              required="#{bindings.PostalCode.hints.mandatory}"
                              columns="#{bindings.PostalCode.hints.displayWidth}"
                              maximumLength="#{bindings.PostalCode.hints.precision}"
                              shortDesc="#{bindings.PostalCode.hints.tooltip}"
                              binding="#{backingBeanScope.backing_dataEntry.it3}"
                              id="it3">
                  <f:validator binding="#{bindings.PostalCode.validator}"/>
                </af:inputText>
                <af:inputText value="#{bindings.City.inputValue}"
                              label="#{bindings.City.hints.label}"
                              required="#{bindings.City.hints.mandatory}"
                              columns="#{bindings.City.hints.displayWidth}"
                              maximumLength="#{bindings.City.hints.precision}"
                              shortDesc="#{bindings.City.hints.tooltip}"
                              binding="#{backingBeanScope.backing_dataEntry.it4}"
                              id="it4">
                  <f:validator binding="#{bindings.City.validator}"/>
                </af:inputText>
                <af:inputText value="#{bindings.StateProvince.inputValue}"
                              label="#{bindings.StateProvince.hints.label}"
                              required="#{bindings.StateProvince.hints.mandatory}"
                              columns="#{bindings.StateProvince.hints.displayWidth}"
                              maximumLength="#{bindings.StateProvince.hints.precision}"
                              shortDesc="#{bindings.StateProvince.hints.tooltip}"
                              binding="#{backingBeanScope.backing_dataEntry.it5}"
                              id="it5">
                  <f:validator binding="#{bindings.StateProvince.validator}"/>
                </af:inputText>
                <af:inputListOfValues id="countryIdId"
                                      popupTitle="Search and Select: #{bindings.CountryId.hints.label}"
                                      value="#{bindings.CountryId.inputValue}"
                                      label="#{bindings.CountryId.hints.label}"
                                      model="#{bindings.CountryId.listOfValuesModel}"
                                      required="#{bindings.CountryId.hints.mandatory}"
                                      columns="#{bindings.CountryId.hints.displayWidth}"
                                      shortDesc="#{bindings.CountryId.hints.tooltip}"
                                      binding="#{backingBeanScope.backing_dataEntry.countryIdId}">
                  <f:validator binding="#{bindings.CountryId.validator}"/>
                </af:inputListOfValues>
                <af:commandButton actionListener="#{bindings.Create.execute}"
                                  text="Create"
                                  disabled="#{!bindings.Create.enabled}"
                                  binding="#{backingBeanScope.backing_dataEntry.cb1}"
                                  id="cb1"/>
                <af:commandButton actionListener="#{bindings.Commit.execute}"
                                  text="Commit"
                                  disabled="#{!bindings.Commit.enabled}"
                                  binding="#{backingBeanScope.backing_dataEntry.cb2}"
                                  id="cb2"/>
              </af:panelFormLayout>
            </af:panelFormLayout>
            <!-- id="af_one_column_stretched"   -->
          </f:facet>
        </af:panelStretchLayout>
      </af:form>
    </af:document>
  </f:view>
  <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_dataEntry-->
</jsp:root>
È stato utile?

Soluzione

Well, I did it! The steps are:

  1. Drop LocationsView1 in a page and select ADF Form...
  2. Drop Create operation from LocationsView1 as a button.
  3. Drop Commit operation as a button
  4. Remove CountryId input text
  5. (Re)Drop CountryId from LocationsView1. When JDeveloper asks, choose Select One Choice...
  6. In Bindings section, select CountryId and edit (pen icon)
  7. Choose Dynamic List radio button and CountriesView1 in ListDataSource combo
  8. Match CountryId from Data Value with CountryId List attribute. Select CountryName in the below section.

Well, finally, all countries from COUNTRIES table are listed, and data are inserted into LOCATIONS table.

I hope this will be useful. Regards

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top