Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Thursday 7 December 2017

Set the Initial Focus on a component in a Page

In ADF, set the initialFocusId property of the af:document to set the focus on a Component on initial load  when the full page renders.

Note that if you are setting the initialFocusId to a component that is not normally available when rendered on the client, then you will also need to set the clientComponent attribute on that component to 'true'. Also, be aware that initialFocusId will be ignored when accessibility-mode is set to "screenReader"

You have to identify the ID of the component and set it for initialFocusId
Suggestion: Identifiers are relative to the component, and must account for NamingContainers. You can use a single colon to start the search from the root, or multiple colons to move up through the NamingContainers - "::" will pop out of the component's naming container and begin the search from there, ":::" will pop out of two naming containers and begin the search from there, etc.


<f:view>
  <af:document initialFocusId="<ID with relative path>">
   <af:form> ... </af:form>
  </af:document>
</f:view>

To identify the relative path of a component you can use developer toolbar in chorme and Firebug in Firefox (Right click on the component and select inspect element).

Ref: https://docs.oracle.com/html/E12419_09/tagdoc/af_document.html

Wednesday 6 December 2017

Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'row' resolved to null


When we are working with table there are some cases we face the following error:

by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'row' resolved to null


As per my findings, this issue will occur when we are working with LOVs in the table or with the QBE.

Working with LOVs:
   Is primary is part of the LOV then you can face this issue. To fix this issue then the suggested solution is to create surrogate key.

QBE:
   If you face this issue when you try to enable QBE, then make sure that you are not referring to the row in filter facets in the table columns.

By default QBE shows input textbox for all the columns, if you want to show different component like date component or LOV then Filter facets are used to render the different component when QBE is enabled.

  <f:facet name="filter">
     <af:selectOneChoice label="Access Mode" id="soc2" value="#{vs.filterCriteria.AccessMode}" simple="true">
         <af:selectItem label="#{null}" id="si4" value="#{null}"/>
         <af:selectItem label="Public" id="si5" value="1"/>
         <af:selectItem label="Private" id="si6" value="0"/>
     </af:selectOneChoice>
  </f:facet>

If you facing 'Target Unreachable, identifier 'row' resolved to null' issue with QBE then you have to make sure that you are referring to row attribute in the filter facet.
Ex:
<af:selectOneChoice label="Access Mode" id="soc2" value="#{row.bindings.pfscopeBean.AccessMode}" simple="true">

It should refer with the varstatus property like
 <af:selectOneChoice label="Access Mode" id="soc2" value="#{vs.filterCriteria.AccessMode}" simple="true">


Note:
Table definition in the jsff will be like:
<af:table value="#{bindings.myVO1.collectionModel}"
     var="row"
     rows="#{bindings.myVO1.rangeSize}"
     varstatus="vs"
.......
</af:table>

If above suggestion will not work try is by setting changeEventPolisy=ppr for the detail table iterator and the tree binding in the pageDef file

Thursday 9 June 2016

Jdeveloper hangs on wsil connection creation

In JDeveloper 11g if we try to create of test the WSIL connection with wrong detail of URL, username or password, JDeveloper hangs.

Make sure that to provide the correct details of URL, username and password while creating the WSIL connection

To verify the URL, access the same URL in a browser. Provide username and password when it prompts. If you see the response then the URL works fine.

You can see the result like this:

WSIL result when you browse

Note: The URL http://localhost:7001/inspection.wsil is a path that works for the Oracle
SOA Suite 11g environment

JDeveloper will not start and hungs

One of the best solution for this to get resolved..
When you have problem with JDeveloper like not starting or crashing
Delete JDeveloper's system directory from JDeveloper home directory

The default location for JDeveloper home directory will be:
 XP; C:\Documents and Settings\username\Application Data\JDeveloper\
 Windows 7: C:\Users\<username>\AppData\Roaming\JDeveloper\

 Under the JDeveloper home directory you can see a directory named as systemxx.x.x.xx...
Ex : system11.1.1.7.40.64.93 (for JDeveloper 11.1.1.7.0)

First close the JDeveloper and delete the system directory. then after start JDeveloper again, JDeveloper will recreate a new fresh one.
Note: All your JDeveloper settings will be lost on deleting the system directory !!!!

System directory contains the JDeveloper custom settings, if you delete this directory it wont impact your work folder (projects). 

Monday 5 October 2015

Object scopes in Fusion page file cycle

At runtime, there are six types of scopes in a Fusion web application
  • Application scope
  • Session scope
  • Page flow scope
  • View scope
  • Request scope
  • Backing  bean scope
Application scope: The object is available for the duration of the application.

Session scope: The object is available for the duration of the session.

Page flow scope: The object is available for the duration of a bounded task flow.

Request scope: The object is available from the time an HTTP request is made until a response is sent back to the client.

Backing bean scope: Used for managed beans for page fragments and declarative components only, the object is available from the time an HTTP request is made until a response is sent back to the client. This scope is needed for fragments and declarative components because there may be more than one page fragment or declarative component on a page, and to prevent collisions, any values must be kept in separate scope instances. Therefore, any managed bean for a page fragment or declarative component must use backing bean scope.

View scope: The object is available until the view ID for the current view activity changes. This scope can be used to hold values for a given page. However, unlike request scope, which can be used to store a value needed from one page to the next, anything stored in view scope will be lost once the view ID changes.

Monday 29 June 2015

How to know whether current row is new row or from database?

A row or view has four states:
  • New
  • Modified
  • Un-Modified
  • Initialized
To get the state using expression: #{row.row.entities[0].entityState}

You can use this expression to control the display or rows in the UI. Like to display new rows in diff colors.
    Ex: #{row.row.entities[0].entityState==0 ? 'background-color:yellow' :  ''} 
Now in RowImpl, you can access the state using:
    Ex: byte entityState = this.getEntity(0).getEntityState() 

Friday 23 January 2015

How to filter rows in VO

There are different ways to filter the data/rows in a VO.

1. Using Where clause:
  You can use setWhereCluse() method from VO to set filter constraint before calling executeQuery() method to filter data based on the input condition. This means we are appending the where clause while querying the data to the DB. This will take string as in input.
Ex: ViewObjectImpl empVO = am.getEmployeeVO();
   //filtering data using  setWhereClause on employee_id
   empVO.setWhereClause("employee_id=" + empId);
   empVO.executeQuery();
 


Note: Here employee_id is the column name from the db table.

 You can have multiple constraints in where clause just like in sql.
 emp.setWhereClause("employee_id=" + empId + "employee_name like " + empName);

2. Using getFilteredRows(): getFilteredRows() is from VO, this method is used to filter rows based on one column only and returns Row[]. getFilteredRows() returns the Row[] by filtering the rows from VO cache based on the column attribute passed.
Ex: ViewObjectImpl empVO = am.getEmployeeVO();
    //filtering data using  setWhereClause on employee_id
    empVO.executeQuery();
    Row[] rows = empV.getFilteredRows("EmployeeId", empId);


Note: EmployeeId is the attribute name from VO.


3. Using Row Qualifier: Using RowQualifier you can filter the data based on multiple columns from VO cache.
Ex: ViewObjectImpl empVO = am.getEmployeeVO();
    //Create RowQualifier from VO 
    RowQualifier rowQualifier = new RowQualifier(empVO);
    //set where clause to row qualifier 
    rowQualifier.setWhereClause("EmployeeId="+empId+" AND EmployeeName="+empName);
    //get filtered rows using row qualifier 
    Row[] filteredRows = emp.getFilteredRows(rowQualifier);  

Note: EmployeeId & EmployeeName are the attribute names from VO.

Monday 19 January 2015

Select All rows in ADF tabel

I got a requirement to provide 'Select All' option for ADF table. Tried a lot in different ways and finally got the solution with the following approach.

Code in UI:
 
<af:commandToolbarButton partialSubmit="true" text="Select All" id="cb1"
actionListener="#{myBean.selectAllListener}">
</af:commandToolbarButton> 

Code in the bean for selection listener is like this:
public void selectAllListener() {
  RowKeySet rkset = new RowKeySetImpl();
  CollectionModel model = (CollectionModel)myTable.getValue();
  int rowcount = model.getRowCount();
 
  for (int i = 0; i < rowcount; i++) {
     model.setRowIndex(i);
     Object key = model.getRowKey();
     rkset.add(key);
  }
 
  myTable.setSelectedRowKeys(rkset);
}

When we click on 'Select All' button, it will select all the rows from the model, adds to the selected row keys of the table and also displays the selected row count in the 'Rows selected' section in the status bar.

If the selection listener has makeCurrent entry, then the above approach may fail. When you select one row and then go for 'Select All', this wont work  to overcome this issue you can have selection listener code in the bean as follows:

public void selectAllListener() {
  RowKeySet rkset = myTable.getSelectedRowKeys();
  CollectionModel model = (CollectionModel)myTable.getValue();
  int rowcount = model.getRowCount();
 
  for (int i = 0; i < rowcount; i++) {
     model.setRowIndex(i);
     Object key = model.getRowKey();
     rkset.add(key);
  }
}

This means that, you are going to add remaining rows on top of selected rows.

Wednesday 22 October 2014

RowInconsistentException: JBO-25014: Another user has changed the row with primary key

Caused by: oracle.jbo.RowInconsistentException: JBO-25014: Another user has changed the row with primary key oracle.jbo.Key[25544 ]. Sol: when we try to commit or executeQuery on a row which is already modified and comitted by another vo/am, this issue occurs. so if you know that there are chanses of updating by another vo, then better to commit or rollback the existing changes then do EO clear chache.
 service.getDBTransaction().commit();
 service.getDBTransaction().clearEntityCache("oracle.apps.msc.ascp.itemsimulation.model.entity.ItemAttributesEO");
 mscItemAttributesVO.executeQuery();

How to load external javascript or css files in jsff?

Guys, if you want to use external javascript or css, you can use af:resource tag in jsff page.
<source>
  <af:resource source="/customStyles.css" type="css"></af:resource>
</source>
In-line CSS content:
<source>
  <af:resource type="css">
    DIV.customStyle { color: red; }
  </af:resource>
</source>
Include an external JS file:
<source><  af:resource source="/customCode.js" type="javascript"></af:resource></source>
In-line JavaScript code:
<source>
  <af:resource type="javascript">
    function clientListenerFunction(event)
    {
       // content ...
    }
  </af:resource>
</source>

Wednesday 27 August 2014

How to Get Application module object programmatically


You can use any of the below methods to get the application module programmatically.
>> private EmployeeAMImpl getAm() {

        FacesContext fctx = FacesContext.getCurrentInstance();
        DCBindingContainer dc =
            (DCBindingContainer)fctx.getApplication().getExpressionFactory().createValueExpression(fctx.getELContext(),
                                                                                                   DCBindingContainer.class).getValue(fctx.getELContext());
        return (WorkbenchAMImpl)dc.findDataControl("EmployeeAMDataControl").getApplicationModule();
    }
    

>> private EmployeeAMImpl getAm() {
        
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp =
            elFactory.createValueExpression(elContext, "#{data.EmployeeAMDataControl.dataProvider}",
                                            Object.class);
        return (WorkbenchAMImpl)valueExp.getValue(elContext);
    }
 

Missing IN and OUT parameters

If you are using bind variables as part of the VO query, then

Make sure that, Required property is enabled for the bind variables which are used in the query.

Programmatic validation UI side

1.Class implements Validator{
2.    @Override
    public void validate(FacesContext facesContext, UIComponent uIComponent,Object newValue) throws ValidatorException {
       String val = String.valueOf(newValue);     
        if (val != null) {
            if (!getMethodResult(val)) {
                throw new ValidatorException(new FacesMessage("Name " + val + " already exists."));
            }
        }
    }

    public boolean getMethodResult(String name) {
        ViewObjectImpl vo = this.getAm().getVo1();
        RowQualifier rowQualifier = new RowQualifier(vo);
                rowQualifier.setWhereClause("Name='"+name+"'");
                Row[] rowsList = vo.getFilteredRows(rowQualifier);
                if(rowsList.length>0){
                        return false;
                    }
                return true;
    }

3. in jsff validator="#{backingBeanScope.myManagedBean.validate}"

Tuesday 30 April 2013

How to Stretch an ADF Table to occupy maximum width

ADF Table can be stretched to occupy the maximum width available by using AFStretchWidth Style Class.
Table can be embedded inside PanelStretchLayout or PanelCollection component

For PanelStretchLayout component the Table must be embedded inside the center facet, and the Style Class of both the Table and Layout component must be set to AFStretchWidth.
        <af:panelStretchLayout id="psl1">
          <f:facet name="bottom"/>
          <f:facet name="center">
            <af:table inlineStyle="AFStretchWidth" ...>
               ....
           </af:table>
          </f:facet>
          <f:facet name="start"/>
          <f:facet name="end"/>
          <f:facet name="top"/>
        </af:panelStretchLayout>

instead of using AFStretchWidth, you can decide which column will get stretched using the attribute columnStretching for example:
columnStretching="last"

  
 <af:table ... columnStretching="columnId_that_you_want_to_stretch" ...>

Friday 19 April 2013

Problem with the taskflow invocation


If you face the following below error when rending the page, then the issue with the region with the task-flow:

java.lang.IllegalStateException: Attempt to validate an already invalid RegionSite

Solution is here:
Just set the following properties to the task-flow binding

go to bindings tab, select task-flow, then go to properties widow set
          activation: immediate,   Refresh: ifneeded

How to get Selected graph point details in ADF Graphs

To get the selected graph point information u need to set the click listener for the graph:

dvt:barGraph should have the clickListener
< dvt:barGraph id="Graph1"
value="#{bindings.View1.graphModel}"
subType="BAR_VERT_CLUST"
clickListener="#{MyBeab.clickAction}" ...>

In bean the clickListener should be implemented as follows:
 void processClick(ClickEvent event)
{
     ComponentHandle handle = event.getComponentHandle();
     if (handle instanceof DataComponentHandle)
     {
         DataComponentHandle dhandle = (DataComponentHandle)handle;
         // Get the value displayed in the series
         System.out.println("Value: " + dhandle.getValue(DataComponentHandle.UNFORMATTED_VALUE));
 
         // Get the series attributes
         Attributes [] seriesInfo = dhandle.getSeriesAttributes();
         if(seriesInfo != null)
         {
             for(Attributes attrs: seriesInfo)
             {
                 System.out.println("Series value: " + attrs.getValue(Attributes.LABEL_VALUE));
                 System.out.println("Series name: " + attrs.getValue(Attributes.LABEL_ATTRIBUTE));
                 System.out.println("Series value id: " + attrs.getValue(Attributes.ID_VALUE));
                 System.out.println("Series name id: " + attrs.getValue(Attributes.ID_ATTRIBUTE));
             }
         }
         // Get the group attributes
         Attributes [] groupInfo = dhandle.getGroupAttributes();
         if(groupInfo != null)
         {
             for(Attributes attrs: groupInfo)
             {
                 System.out.println("Group value: " + attrs.getValue(Attributes.LABEL_VALUE));
                 System.out.println("Group name: " + attrs.getValue(Attributes.LABEL_ATTRIBUTE)); 
             }
         }
     }
 }