Thursday, December 30, 2010

java.lang.RuntimeException: cannot find FacesContext

Had been googeling for this for quite a long time and the answer was always about wrong url-patterns or incorrect servlet-mapping in web.xml etc

However, the problem is not with the URL pattern. Make sure that the jspx contains the following pattern.

<?xml version='1.0' encoding='windows-1252'?>
<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=windows-1252"/>
<f:view>
<af:document id="d1">
<af:messages id="m1"/>
</af:document>
</f:view>


Tip:- When you're using Applcore components in your UI, preferably use Fusion schema with fusion/fusion in jdev database connection. Also, never change any passwords either in the properties file or in the console. Let the defaults be.

Tuesday, December 28, 2010

Steps for creating a sample Fusion Web Application (ADF)

1. File->New->General->Applications->Fusion Web Application(ADF)
2. Specify an application name
3. Specify a name for the Model project. Go with the default selected technologies (ADF Business components, Java). Go with the default package.
4. Specify a name for the ViewController project. Go with the default selected technologies (ADF Faces, ADF Page Flow, HTML, Java, JSF, JSP and Servlets,
XML).
Go with the default package.
5. Right-click on the Model project -> Business Tier -> ADF Business Components -> Entity Object
6. Initialize Business Components Project - > Create a database connection. Click the '+' button and enter the following details :-
Connection Name : ApplicationDB
Username : scott Password : tiger
Hostname : indl144229.idc.oracle.com Port : 1522 Sid in144229
Do a Test Connection to make sure it shows a 'Success'.
7. Give an appropriate name for the Entity Object that you wish to create. You can choose a customised package where you want to place your entity
objects
else go with the default choice.
8. You can choose a schema object on which you want to base your entity object by clicking on the Browse button next to the 'Schema Object' dropdown.
The database schema shown will be SCOTT since we gave credentials to login to the database in the previous step as (scott / tiger)
9. You can choose the EMP table for example to model your entity and View objects.
10. The next screen will show you the list of 'Attributes' corresponding to the table columns. You can choose to order them in the required manner.
11. The next step is the 'Attribute Settings' where you have to choose an attribute as the Primary Key.
12. The next step 'Java' allows you to choose to generate :- EntityObjectClass (eg : SampleEOImpl) , Entity Collection Class (eg : SampleEOCollImpl) and
Entity Definition Class (eg : SampleEODefImpl)
13. The next step 'Generate' allows you to create ViewObject and Application Module for the entity object you created in the previous step. You can choose to
place them in appropriate packages.
14. The next step which is Summary shows you a summary of all the above steps and what options you chose in each of them.
15. Right click on ViewController Project -> Web Tier -> JSF -> JSF Page Fragment. Give a name to the jsff page that you want to create and choose the
package
you want to place it in.
16. In the data controls section, you will find a data control (DC) corresponding to your Application Module. On expanding this DC you will find a control
corresponding to the ViewObject and its Operations. You can drag drop this control onto the jsff page fragment that you just created in various different
forms ( popup, Form, Gantt, Gauge, Geographical Map, Graph, Multiple Selection, Navigation , Single Selection, Table, Tree)
17. Create a bounded task flow inside which you can place the jsff created in the above step. Right click ViewController -> Web Tier -> JSF -> ADF Taskflow
Give an appropriate name for the taskflow and place it in a separate package.
18. Now drag and drop the jsff page fragment onto the taskflow you created in the above step. In case you do not plan to place anything inside the
adfc-config.xml (which is the default unbounded taskflow and starting point for an application), then you need to mark the page fragment inside this
taskflow as the 'Default Activity'.
19. Create a new jspx page as : Right click ViewController -> Web Tier -> JSP -> JSP : say start.jspx. Place the taskflow inside this jspx page.
Now goto the page bindings of the jspx page. Here, click on the taskflow and in the property-inspector, set the activation property to 'immediate'
20. You can optionally place the start.jspx page inside adfc-config.xml, which will become the starting point of your application. Else the jspx itself would be
the starting point.

Monday, December 27, 2010

Perm gen space error in jdev

The Perm gen space often appears in jdeveloper when you re-run a UI application without stopping the server. This error can be avoided by adding the following to the project properties JAVA OPTIONS :-

Project Properties -> Run/Debug/Profile -> Default -> Edit -> Java Options ->

-Xms256m -Xmx1024m -XX:PermSize=96m -XX:MaxPermSize=512m -XX:CompileThreshold=8000

Thursday, December 23, 2010

Making the columns of an ADF table resizable

The columns of an ADF table can be made re sizable using column level attributes width and minimumWidth. Either absolute numbers or percentages can be used to make them re sizable.

width :The width of the column. The default width for a column is 100px. There is no auto sizing for columns. Set the width attribute to ensure the column is wide enough to accommodate the width of the contents.

minimumWidth : The minimum number of pixels that the column can become. When a user attempts to resize a column, this minimumWidth will be enforced. Also, when a column is flexible, it will never be stretched to be a size smaller than this minimumWidth. If a pixel width is defined and if the minimumWidth is larger, the minimumWidth will become the smaller of the two values. By default the minimum width is 12 pixels. This attribute is not supported on the following agent types :- phone and voice.


Example :-

<af:column align="right"
 headerText=
 "#{bindings.ForecastItemDetail.hints.WinProb.label}(%)"
 id="c26" sortProperty="WinProb"
 sortable="true">
  <af:outputText id="ot47"
  value="#{row.WinProb}">
  <af:convertNumber pattern="#{applCorePrefs.numberFormatPattern}"
    type="number"/>
  </af:outputText>
  <f:facet name="footer">
   <af:outputText value="outputText7"
    id="ot24" visible="false"/>
  </f:facet>
 </af:column>


Tip:- In case of an ADF applications table, if a detailStamp or a ShowDetail column is part of the table, then the column resize does not work as expected.

Tuesday, December 21, 2010

Deployment exception : Domain edit lock owned by another session

If you get an exception in deployment..and the Error reads something like :-

"Deployer:149164The domain edit lock is owned by another session in exclusive mode - hence this deployment operation cannot proceed"

Then...

a) Go to domainHome folder and delete edit.lok file.
b) Restart your server.


That solves the deployment exception!

What is the execution phase inside VoRowImpl file?

Problem Description :

When we code logic inside the VoRowImpl file for making any changes to a UI page through a VO, we make use of the getters and setters of the VO attributes. Normally, for displaying any data on the UI page, the getters are called first. When the values to any of these attributes change, we make use of the setters to set new values. After this, the getters are again called in order to display the new values on the UI page.

But, at point in time, is there any way to know where exactly we are like :

1. Initial getters phase that displays the old values in the database
2. Setters phase which sets the modified values to the attributes.
3. Final getters phase which displays the modified values in the database.


Solution:

Not sure why you need to know this. An EO can be used in UI, and other batch program/service where these phases don't make sense.

You can always check the EO state (postState for example) to examine whether an EO is an existing and not modified, or modified, or new, etc.

Monday, December 20, 2010

ADFUItable : getSelectedRowKeys()

getSelectedRowKeys

public Object getSelectedRowKeys()

Get function for attribute for 'selectedRowKeys'.
Return:
Object - SelectedRowKeys


The following code snippet is an example of how this particular attribute of the ADFUItable can be used.

AdfFacesContext.getCurrentInstance().addPartialTarget(this.dialog1);                  
DCIteratorBinding iter = this.findIterator("OrderLineChargesIterator");
DCDataControl dc  = iter.getDataControl();                      
ApplicationModule amMod1=(ApplicationModule)dc.getDataProvider();        
NegotiateAMImpl amMod = (NegotiateAMImpl)amMod1;           
      
RowKeySet rowkeyset = this.table2.getSelectedRowKeys();
Iterator itr = rowkeyset.iterator();
int countOfSelectedRows = this.table2.getSelectedRowKeys().getSize();
      
ViewObject vo =  this.findIterator("OrderLineCharges1_1Iterator").getViewObject();
vo.clearCache();
       
ViewObject targetsetvo = this.findIterator("TargetSetIterator").getViewObject();
ViewObject adjustmentsetvo = this.findIterator("AdjustmentSetIterator").getViewObject();

Row  selchargesrow = targetsetvo.createRow();
selchargesrow.setAttribute("PriceType","SelectedCharges");
       
while (itr.hasNext())
{
  this.table2.setRowKey(itr.next());
  FacesCtrlHierNodeBinding f = (FacesCtrlHierNodeBinding)this.table2.getRowData();
                
  if(countOfSelectedRows > 0)
  {               
     targetsetvo.insertRowAtRangeIndex(0,selchargesrow);
     adjustmentsetvo.insertRowAtRangeIndex(0,selchargesrow);
  }                                     
  vo.insertRow(f.getRow());
  FacesCtrlHierNodeBinding f1 =(FacesCtrlHierNodeBinding)this.table2.getSelectedRowData();
  Row rw=f1.getRow();
          
}
amMod.GetTargetSetValues(countOfSelectedRows);

Friday, December 17, 2010

TO_CHAR to TO_DATE

Problem description:
“I’m trying to apply a view criteria programmatically here. When the bind variable for “StartDate” (which is a VO attribute) uses just a “=”. then at runtime the VC gets appended to the query using a TO_DATE for the bind var, which is as expected. However, when the bind variable for “StartDate” uses just a “>=” / “<”>” . then at runtime the VC gets appended to the query using a TO_CHAR for the bind var, which is not that we require. Is there any way to get a TO_DATE for this kind of comparison as well?”
Please take a look at the following sample method :-

public Row getSampleHeaderVORecord(Date activeDate) {
ViewObjectImpl SampleHeaderVO = getSampleHeader1();
ViewCriteria viewCriteria = SampleHeaderVO.createViewCriteria() ;
ViewCriteriaRow vcr1 = viewCriteria.createViewCriteriaRow() ;
vcr1.setAttribute("StartDate", ">="+(activeDate.));
viewCriteria.add(vcr1);
SampleHeaderVO.applyViewCriteria(viewCriteria);
SampleHeaderVO.executeQuery();
return SampleHeaderVO.next();
}

Sample query that appears at runtime :-

SELECT *WHERE ( ( (TO_CHAR( ForecastHeaderEO.START_DATE, 'yyyy-mm-dd') > '0007-04-02' ) ) )The TO_CHAR in the last line is what I’m referring to. Is there any way to get a TO_DATE there?
Solution:
ViewObjectImpl SampleHeaderVO = getSampleHeader1(); ViewCriteria viewCriteria = SampleHeaderVO.createViewCriteria() ; ViewCriteriaRow vcr1 = viewCriteria.createViewCriteriaRow() ; ViewCriteriaItem vci = vcr1.ensureCriteriaItem("StartDate"); vci.setOperator(JboCompOper.OPER_ON_OR_AFTER); vci.setValue(activeDate); viewCriteria.add(vcr1); SampleHeaderVO.applyViewCriteria(viewCriteria); SampleHeaderVO.executeQuery();