adf常用方法總結


1.使用clientAttribute傳值、獲取值 或組件上面放客戶端屬性 

<af:selectBooleanCheckbox text="" label="" id="sbc1" autoSubmit="true"  valueChangeListener="#{viewScope.BulkProcessBean.onSelect}"> 
        <af:clientAttribute name="employeeId" value="#{row.EmployeeId}"/> 
</af:selectBooleanCheckbox>

public void onSelect(ValueChangeEvent valueChangeEvent) { 
         Number id = (Number)valueChangeEvent.getComponent().getAttributes().get("employeeId"); 
... 
} 

  

注意:客戶端屬性名不能與其父組件的屬性名重復,否則會得到第一個屬性名的值,這里的employeeId必須是和selectBooleanCheckbox的屬性名不同。
又例: 

<af:commandButton text="財務退回" id="cb1" binding="#{tuiDanBean.eprebateBackBtn}" action="#{tuiDanBean.eprebateBack_action}"> 
     <af:clientAttribute name="status" value="#{row.Status}"/> 
</af:commandButton> 
//bean中獲取屬性值 
String num =String.valueOf(eprebateBackBtn.getAttributes().get("status")); 

 

2.為id設置seqence值

(new oracle.jbo.server.SequenceImpl("employees_seq",object.getDBTransaction())).getSequenceNumber() 

  


在eo中設置目標屬性 勾選表達式 然后編輯值。


3.根據table創建行 並賦值
1

CollectionModel _tableModel = (CollectionModel)table.getValue(); 
JUCtrlHierBinding _adfTableBinding =(JUCtrlHierBinding)_tableModel.getWrappedData(); 
DCIteratorBinding it = _adfTableBinding.getDCIteratorBinding();

oracle.jbo.Row row_adf = null; row_adf = it.getNavigatableRowIterator().createRow(); 
row_adf.setNewRowState(oracle.jbo.Row.STATUS_INITIALIZED); 
it.getNavigatableRowIterator().insertRow(row_adf); 
row_adf.setAttribute("DepartmentId",row_poi.getCell(0).getNumericCellValue()); 

  

2

CollectionModel _tableModel = (CollectionModel)eprebateTable.getValue(); 
JUCtrlHierBinding _adfTableBinding = (JUCtrlHierBinding)_tableModel.getWrappedData(); 
DCIteratorBinding it = _adfTableBinding.getDCIteratorBinding(); 
NavigatableRowIterator iterator = it.getNavigatableRowIterator(); 
Row row=iterator.createRow(); 
row.setNewRowState(oracle.jbo.Row.STATUS_NEW); 
row.setAttribute("Num", 4); 
iterator.insertRow(row); 

  


3

import oracle.binding.BindingContainer; 
import oracle.binding.OperationBinding;

BindingContainer bindings = getBindings(); OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert1"); 
operationBinding.execute(); 
CollectionModel _tableModel = (CollectionModel)eprebateTable.getValue(); 
JUCtrlHierBinding _adfTableBinding = (JUCtrlHierBinding)_tableModel.getWrappedData(); 
DCIteratorBinding it = _adfTableBinding.getDCIteratorBinding(); 
NavigatableRowIterator iterator = it.getNavigatableRowIterator(); 
Row currentRow = iterator.getCurrentRow(); 
currentRow.setAttribute("Num", iterator.getRowCount()); 

  

注意:以上三種方式需要在頁面中對table進行綁定,第三種還要做操作綁定。


4.得到頁面table的迭代器

    private NavigatableRowIterator getTableIter(RichTable table) {
        CollectionModel _tableModel = (CollectionModel) table.getValue();
        JUCtrlHierBinding _adfTableBinding = (JUCtrlHierBinding) _tableModel.getWrappedData();
        DCIteratorBinding it = _adfTableBinding.getDCIteratorBinding();
        return it.getNavigatableRowIterator();
    }

  

        NavigatableRowIterator iterator = getTableIter(vflistTable); 
        Row currentRow = iterator.getCurrentRow(); 
        currentRow.setAttribute("Status", 0); 
        currentRow.setAttribute("Isback", "1"); 
        am.getTransaction().commit(); 

  

 

5.格式化時間

        import java.util.Date; 
        import java.text.SimpleDateFormat;

        SimpleDateFormat sdf = new SimpleDateFormat(); 
        sdf.applyPattern("yyyyMMdd"); 
        //以上兩句可寫成

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); 
        Date date = new Date(); 
        String second = sdf.format(date); 
        //如果還要時分秒: HH:mm:ss 
        //注意:如果是時間類是oracle.jbo.domain.Date用 
        sdf.format(currDate.dateValue()) 

 

6.必填 必選
<af:outputLabel value="*" inlineStyle="color:Red;"/>

showRequired="true" 顯示藍色星號 不填沒有錯誤信息 加上
autocommit=true 不填有錯誤信息
required="true" 顯示藍色星號 不填有錯誤信息
requiredMessageDetail="沒錢不干活啊" 顯示錯誤信息

 

7.下面的程序使用param隱含對象來取得使用者輸入的參數以及一些
jsf基礎知識: 

    <html>
        <head>
            <title></title>
        </head>
        <body>
            <view>
                <b>您好,
                    <outputText value="#{param.name}"/></b>
            </view>
        </body>
    </html>

 

param是JSF-EL預設的隱含對象變量它代表request所有參數的集合,實際是一個java.util.Map型態對象,JSF所提供的隱含對象,大致上對應於JSP隱含物件不過JSF隱含

對象移除了pageScope與 pageContext,而增加了facesContext與view它們分別對應於javax.faces.context.FacesContext與 javax.faces.component.UIViewRoot。

對於Map型態對象,我們可以使用 '.' 運算子指定key值來取出對應的value也可以使用 [ ] 來指定,例如:

     <f:view>
            <b>您好,
                <outputText value="#{param['name']}"/></b>
        </f:view>

在 [ ] 之間也可以放置其它的變量值,例如:

1  <f:view>
2             <outputText value="#{someBean.someMap[user.name]}"/>
3         </f:view>


如果變量是List型態或數組的話,則可以在 [] 中指定索引,例如:

1         <f:view>
2             <outputText value="#{someBean.someList[0]}"/>
3             <outputText value="#{someBean.someArray[1]}"/>
4             <outputText value="#{someBean.someListOrArray[user.age]}"/>
5         </f:view>


您也可以指定字面常數,對於true、false、字符串、數字,JSF EL會嘗試進行轉換,例如:

<h:outputText value="#{true}"/> 
<h:outputText value="#{'This is a test'}"/> 


如果要輸出字符串 必須以單引號 ' 或雙自變量 " 括住,如此才不會被認為是變量名稱。

在宣告變量名稱時 要留意不可與JSF的保留字或關鍵詞同名,例如 :
不可取以下這些名稱

true false null div mod and or not eq ne lt gt le ge instanceof empty
2

<h:outputText value="#{user.date}"> 
    <f:convertDateTime pattern="dd/MM/yyyy"/> 
</h:outputText> 

 


3

 1 <html>
 2     <head>
 3         <title>驗證器示范</title>
 4     </head>
 5     <body>
 6         <view>
 7             <messages layout="table" style="color:red"/>
 8             <form>
 9                 <h3>請輸入您的名稱</h3>
10                 <outputText value="#{user.errMessage}"/>
11                 <p>
12                     名稱: 
13                     <inputText value="#{user.name}" required="true"/>
14                     <p>
15                         密碼: 
16                         <inputSecret value="#{user.password}" required="true">
17                             <validateLength minimum="6"/>
18                         </inputSecret>
19                         <p>
20                             <commandButton value="送出" action="#{user.verify}"/>
21                         </p>
22                     </p>
23                 </p>
24             </form>
25         </view>
26     </body>
27 </html> 

 


在<h:inputText>、</h:inputSecret>中我們設定了required屬性為 true這表示這個字段一定要輸入值我們也在</h:inputSecret>設定了<f: validateLength>,並設定其minimum屬性為6,

這表示這個字 段最少需要6個字符。這一次在錯誤訊息的顯示上 我們使用<h:messages>標簽,當有驗證錯誤發生時 相關的錯誤訊息會收集起來 使用<h:messages>卷標可以一次將所有的錯誤訊息顯示出來。

4

<h:commandButton value="送出" action="#{user.outcome}"> 
   <f:actionListener type="onlyfun.caterpillar.LogHandler"/> 
   <f:actionListener type="onlyfun.caterpillar.VerifyHandler"/> 
</h:commandButton> 

5
outputFormat
產生指定的文字訊息 可以搭配<f:param>來設定訊息的參數以格式化文字訊, 例如

<f:loadBundle basename="messages" var="msgs"/> 
  <h:outputFormat value="#{msgs.welcomeText}"> 
  <f:param value="Hello"/> 
  <f:param value="Guest"/> 
</h:outputFormat> 

 


如果您的messages.properties包括以下的內容

welcomeText={0}, Your name is {1}. 則{0}與{1}會被取代為<f:param>設定的文字 最后顯示的文字會是

Hello, Your name is Guest.
另一個使用的方法則是

<h:outputFormat value="{0}, Your name is {1}."> 
   <f:param value="Hello"/> 
   <f:param value="Guest"/> 
</h:outputFormat> 

 


6
inputSecret
顯示密碼輸入字段 即輸出<input> HTML卷標 其type屬性設定為
password 例如

<h:inputSecret value="#{user.password}"/>
您可以設定redisplay屬性以決定是否要顯示密碼字段的值 預設是
false。

inputHidden
隱藏字段 即輸出<input> HTML卷標 其type屬性設定為hidden
隱藏字段的值用於保留一些訊息於客戶端 以在下一次發送窗體時一並
送出 例如
<h:inputHidden value="#{user.hiddenInfo}"/>


7
如果搭配<f:param>來使用則所設定的參數會被當作請求參數一並送出,例如

<h:commandLink> 
  <h:outputText value="welcome"/> 
  <f:param name="locale" value="zh_TW"/> 
</h:commandLink>

 


8.從數據庫中拿數據
vo.setWhereCluse()
executeQuery
AdfFacesContext.getCurrentInstance.addPerttrigger(table)


9.ADF的scope獲取方式 

        ADFContext.getCurrent().getApplicationScope(); 
        ADFContext.getCurrent().getSessionScope(); 
        AdfFacesContext.getCurrentInstance().getPageFlowScope();

        ADFContext.getCurrent().getRequestScope(); 
        ADFContext.getCurrent().getViewScope();


        Map<String, Object> applicationScope = ADFContext.getCurrent().getApplicationScope();

        Map sessionScope = ADFContext.getCurrent().getSessionScope();

        Map<String, Object> flowScope = AdfFacesContext.getCurrentInstance().getPageFlowScope();

        Map<String, Object> map = AdfFacesContext.getCurrentInstance().getViewScope();

        Map requestScope = ADFContext.getCurrent().getRequestScope();

        Map<String, Object> scope = ADFContext.getCurrent().getViewScope(); 
    }

 


10.JSF布局排版兩個組件,<h:panelGrid>、<h:panelGroup>
<h:panelGrid> 這個卷標可以用來作簡單的組件排版,它會使用HTML表格卷標來繪制表格,並將組件置於其中,主要指定columns屬性,如設定為 2

<h:panelGrid columns="2"> 
   <h:outputText value="Username"/> 
   <h:inputText id="name" value="#{userBean.name}"/> 
   <h:outputText value="Password"/> 
   <h:inputText id="password" value="#{userBean.password}"/> 
   <h:commandButton value="submit" action="login"/> 
   <h:commandButton value="reset" type="reset"/> 
</h:panelGrid> 

 


則自動將組件分作 2 個 column來排列,注意 <h:panelGrid>的本體間只能包括JSF組件,如果想要放入非JSF組件,例如簡單的樣版,emplate,文字,則要使 <f:verbatim>包括住,例如 

<h:panelGrid columns="2"> 
   <f:verbatim>Username</f:verbatim> 
   <h:inputText id="name" value="#{userBean.name}"/> 
   <f:verbatim>Password</f:verbatim> 
   <h:inputText id="password" value="#{userBean.password}"/> 
   <h:commandButton value="submit" action="login"/> 
   <h:commandButton value="reset" type="reset"/>
 </h:panelGrid>

 

 

這個組件用來將數個JSF組件包裝起來使其看來像是一個組件例
如

<h:panelGrid columns="2"> 
   <h:outputText value="Username"/> 
   <h:inputText id="name" value="#{userBean.name}"/> 
   <h:outputText value="Password"/> 
   <h:inputText id="password" value="#{userBean.password}"/> 
   <h:panelGroup> 
      <h:commandButton value="submit" action="login"/> 
      <h:commandButton value="reset" type="reset"/> 
   </h:panelGroup> 
</h:panelGrid>

 


11.為table中的字段添加排序、過濾
<af:column
headerText="#{bindings.CdsExportEprebateView2.hints.Vfno.label}"
id="c1" filterable="true" sortable="true" sortProperty="Vfno">
<af:outputText value="#{row.Vfno}"
id="ot2"/>
</af:column>
只讀的字段生成之后不能排序不能過濾這時候需要加上幾個屬性
filterable="true" sortable="true" sortProperty="Vfno"
--------------------------------------------------------------------
12.在vo上增加條件查詢並應用條件查詢
條件查詢名字filterByDept
條件查詢條件( (Employees.DEPARTMENT_ID = :deptId ) )
應用條件查詢
public void applyEmplyeeCriteria(Integer deptId){
ViewObjectImpl employees =
(ViewObjectImpl)findViewObject("Employees");
employees.setApplyViewCriteriaNames(null);
ViewCriteria criteria =
employees.getViewCriteria("filterByDept");
employees.applyViewCriteria(criteria);
employees.ensureVariableManager().setVariableValue("deptId",
deptId);
employees.executeQuery();
} -------------------------------------------------------------------
13.彈出消息框
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public static void popupMessage(String level,String detail){
FacesMessage fm = new FacesMessage(null,detail);//默認級別
為info
if("info".equals(level))
fm.setSeverity(fm.SEVERITY_INFO);
else if("warn".equals(level))
fm.setSeverity(fm.SEVERITY_WARN);
else if("error".equals(level))
fm.setSeverity(fm.SEVERITY_ERROR);
else if("fatal".equals(fm.SEVERITY_FATAL))
fm.setSeverity(fm.SEVERITY_FATAL);
FacesContext.getCurrentInstance().addMessage(null, fm);
}
-------------------------------------------------------------
14.行拷貝 代碼中進行row copy
//將one里的某些字段值copy給currentRow
private void setApplyAttribute(Row currentRow,Row one,String...columns){
//不要空指針
if(currentRow==null || one==null || columns.length==0)
return;
//循環賦值
for(String s:columns)
if(one.getAttribute(s)!=null)
currentRow.setAttribute(s, one.getAttribute(s));
}
----------------------------------------------------------
15.頁面三目表達式判斷形式
#{(row.Datastate eq '0') ? '正常':((row.Datastate eq '1') ? '暫存':'刪除')}

inlineStyle="background-color:#{(row.Canmerge == '1')? ((row.Ismother == '0')? 'yellow' : ''):''};"readOnly="#{bindings.Marginal!=null}" 

---------------------------------------------------------

16.安全驗證重定向到另一個URL
ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
String url = ectx.getRequestContextPath()+”/adfAuthentication?logout=true&am p;end_url=/faces/start.jspx”;
try {
response.sendRedirect(url);
} catch (Exception ex) {
ex.printStackTrace();
}
---------------------------------------------------------
17.刷新控件PPR
AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponent);
---------------------------------------------------------
18.查找控件
private UIComponent getUIComponent(String name) {
FacesContext facesCtx = FacesContext.getCurrentInstance();
return facesCtx.getViewRoot().findComponent(name) ;
}
---------------------------------------------------------

19.獲取table選中的行(不一定是當前行)
RowKeySet selection = resultTable.getSelectedRowKeys();
Object[] keys = selection.toArray();
List receivers = new ArrayList(keys.length);
for ( Object key : keys ) {
User user = modelFriends.get((Integer)key);
}
// 獲取table選中的行的另一種
for (Object facesRowKey : table.getSelectedRowKeys()) {
table.setRowKey(facesRowKey);
Object o = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
Row row = rowData.getRow();
Test testRow = (Test)((DCDataRow)row).getDataProvider() ;
}
------------------------------------------------------------------
20.在eo實現類中 這個好搞個方法驗證
public boolean validateLength(Number length) {
if(length!=null && String.valueOf(length).contains("."))
return false;
return true;
} ------------------------------------------------------------------
21.應用條件查詢並設置參數值
public void applyJobCriteria(String title){
ViewObjectImpl employees =
(ViewObjectImpl)this.getJobsView1();
employees.setApplyViewCriteriaNames(null);
ViewCriteria criteria =
employees.getViewCriteria("JobsViewCriteria");
employees.applyViewCriteria(criteria);
employees.ensureVariableManager().setVariableValue("titleVar",
title);
employees.executeQuery();
employees.setApplyViewCriteriaNames(null);
}
---------------------------------------------------------------
22.開發人員可以通過繼承javax.faces.event包中PhaseListener接口實
現階段listener這個接口定義了3個方法

PhaseId getPhaseId()
void afterPhase(PhaseEvent)
void beforePhase(PhaseEvent)

getPhaseId方法返回何時提交階段事件到listener在不指定階段的情
況下階段listener的beforePhase和afterPhase方法將在每個生命周
期中調用6次即每個生命周期階段調用一次。
但是上面這樣不指定生命周期階段的用法通常情況下是不合理的如果
不指定階段則意味着所有階段都會執行代碼在實際的應用中不太可能
需要這樣

而如果你的邏輯處理需要花費很長時間的話由於錯誤的使用可能導致
頁面顯示的嚴重性能問題因此在往beforePhase和afterPhase方法中
添加業務邏輯時

需要明確根據階段來執行明確指定在哪個階段執行代碼


public class CustomPhase implements PhaseListener {

public void beforePhase(PhaseEvent e) {
if(e.getPhaseId == PhaseId.INVOKE_APPLICATION) {
System.out.println("BEFORE " + e.getPhaseId());
}
}
public void afterPhase(PhaseEvent e) {
if(e.getPhaseId == PhaseId.INVOKE_APPLICATION) {
System.out.println("AFTER " + e.getPhaseId());
}
}
}
------------------------
23.頁面定義js的兩種方法
<af:document>
<af:resource type="javascript" source="/customJsCode.js"/>

</af:document>

<af:document>
<af:resource type="javascript">
function customJsFunction(){ … }
</af:resource>

</af:document>
--------------------------
24.頁面傳參 js調用 <af:clientAttribute name="rowKey"
value="#{row.rowKeyStr}"/>
<af:clientListener method="handleDepartmentClick"
type="click"/>

<af:document>
<af:messages/>
<f:facet name="metaContainer">
<af:group>
<script>
function handleDepartmentClick(evt){
rowKey = evt.getSource().getProperty("rowKey");
alert(rowKey);
}
</script>
</af:group>
</f:facet>
...
</af:document>
-----------------------------
25.正則表達式驗證
<af:validateRegExp pattern="[^.]*" hint="提示" messageDetailNoMatch="必須輸入整數"/>

----------------------------
26.
安全退出 注銷
FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();
String url = ectx.getRequestContextPath() +
"/adfAuthentication?logout=true&end_url=/faces/Home.jsp
x";
try {
ectx.redirect(url);
} catch (IOException e) {
e.printStackTrace();
}
fctx.responseComplete();
return null;
-----------------------------------------------
27.ADF中怎樣獲取訪問web.xml中的參數值
web.xml中的參數值可以提供給應用一些特殊的配置信息
How-to read context parameters in web.xml from ADF?
Context parameters in web.xml can be used to provide application specific configurations to ADF. To
access context parameters in ADF, you use the FacesContext static
context class as shown below

FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();
ServletContext servletContext = (ServletContext) ectx.getContext();
String myContextParam =
(String)servletContext.getInitParameter("mycontextparam");

-------------------------------------------------
28.this.getDBTransaction().postChanges()
//也讓它從緩存中查詢滿足條件的記錄 但是這個會有一些操作上的隱

-------------------------------------------------
29.Row 、Number 的api位置
import oracle.jbo.Row;
import oracle.jbo.domain.Number;
-------------------------------------
30.創建一條有外鍵link的記錄 需要先拿到主表的row然后create

//創建一條對應的eta記錄 
ViewRowSetImpl vrsi=(ViewRowSetImpl)row.getAttribute("CdsExportEtaView"); 
Row etaRow = vrsi.createRow(); 
vrsi.insertRow(etaRow); 
am.getDBTransaction().commit(); 

  


---------------------------------
31.從請求中獲取url信息
request.getHeader("Host")--->127.0.0.1:7101
request.getContextPath()--->/cds
request.getServletPath()--->/faces
------------------------------
32.寫入文件

InputStream inputStream=new FileInputStream(file); 
InputStreamReader isr=new InputStreamReader(inputStream,"UTF-8"); 
BufferedReader br=new BufferedReader(isr); 
String str; 
while((str=br.readLine())!=null) 
out.write(str.getBytes("UTF-8")); 



33.得到某個迭代器的當前行的某個屬性值

private Object getCurrExportid(){ 
   DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); 
   DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get("CDS_Export_APPLY_ETA1Iterator"); 
   return iterBind.getCurrentRow().getAttribute("Exportid"); 
} 

  


-------------------------------------
34.得到用戶名 安全 

String user = ADFContext.getCurrent().getSecurityContext().getUserName();

  

 

How-to access the username from ADF BC?
To access the username of an authenticated web session in ADF
Business Components, use the security
context as shown below 

ADFContext adfctx = ADFContext.getCurrent(); 
String user = adfctx.getSecurityContext().getUserPrincipal().getName();

  

The security context is also accessible from Groovy in ADF Business Components, for example to define
a bind variable used in a View Criteria that queries View Object data in
the context of the authenticated user 

adf.context.securityContext.userName

The SecurityContext is not available in Oracle JDeveloper releases
before 11g. In older releases, the
authenticated username is accessible from a call to
getUserPrincipalName() on the Application Module
Impl class. This "old" API is still supported but discouraged in favor of
the SecurityContext accessed
from the ADF context.
------------------------------
35.outputLabel和outputText兩者有何不同
outputLabel 文字有顏色,重在label作用
outputText 文字一般,不重在label作用
<af:outputLabel value="稅名稱" id="ol4"/>
<af:outputText value="#{bindings.Tariffcds.inputValue}" id="ot84"/>

36.vo 增加臨時屬性
因戰斗需要 在vo中新增臨時屬性ligangcolor 設置:
type:String
value type:expression
value
關鍵是value的取值 有兩種來源 一種是其他字段的處理值 還有一 種就是自定義值。
自定義值支持Java語言 貌似是groovy語言吧 不確定 以下兩種設
值方式是都是正確的
1 "blue"
2 new String("blue")
這種設置初始值的方式 發現有一個缺點就是頁面第一次加載會卡。
---------------------------------------------------
37.對於一些基本的CUD操作 可以弄個公共方法:
import oracle.adf.model.BindingContext;
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;
/*
*opr操作如delete、commit等
*return操作成功返回true否則返回false
*/
private boolean opr_action(String opr){ BindingContainer bindings =
BindingContext.getCurrent().getCurrentBindingsEntry();;
OperationBinding opr = bindings.getOperationBinding(opr);
opr.execute();
if(!delete.getErrors().isEmpty()){
System.out.println("刪除失敗");
return false;
}else
return true;
}
--------------------------------------
38.在Managed Bean中給ADF RichTable排序 .
1Backing Bean中設置排序方法
public void sortMethod(SortEvent event){
DCIteratorBinding iter = ADFUtils.findIterator("xxxxVOIterator");
String propery = event.getSortCriteria().get(0).getProperty();
String isAsending = event.getSortCriteria().get(0).isAscending()
== true ? "asc" : "desc";
//在內存中排序
ViewObject vo = iter.getViewObject();
vo.setSortBy(propery + " " + isAsending);
vo.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS); vo.executeQuery();
vo.setSortBy(null); //去除排序基准
SortCriteria[] sc = new SortCriteria[0];
iter.applySortCriteria(sc);
}

2在RichTable中添加sort listener事件
<af:table .....
sortListener="#{backing_xxx.sortMethod}"

提示 如果是table中字段的默認升降序排序 可以在dataBingding中
設置各個字段的排序方式。
----------------------------------
39.js運行.exe
function RunExe()
{
var commandtoRun = "C:\\file.exe";
var objShell = new
<strong>ActiveXObject</strong>("Shell.Application");
objShell.<strong>ShellExecute</strong>(commandtoRun, "", "",
"open", 1);
}
--------------------------------
40.彈出消息框
private void popupMessage(String summary,String detail){
FacesMessage fm = new FacesMessage();
fm.setSeverity(fm.SEVERITY_WARN);
fm.setSummary(summary);
fm.setDetail(detail);
FacesContext.getCurrentInstance().addMessage(null, fm);
}
注意以上是彈出消息框的完整代碼已經被收入JSFUtils工具類中
所以你可以簡單使用以下
JSFUtils.addFacesInformationMessage("這是一個一般信息提示框。");
JSFUtils.addFacesErrorMessage("這是一個錯誤信息提示框。");
--------------------------------
41.交通燈示例代碼
<af:column sortProperty="Exc"
filterable="true"
sortable="true"
headerText="#{bindings.CdsImportView
View1.hints.Exc.label}"
id="c1"> <dvt:gauge gaugeType="LED"
ledStyle="LS_DOT"
imageHeight="24"
imageWidth="24"
rendered="true"
textAntialiasing="false"
visualEffects="NONE"
gaugeSetDirection="GSD_DOWN"
thresholdDialStyle="TDS_RING_FILL
"
animationOnDataChange="none"
animationIndicators="NONE"
renderImagemap="false"
flashDefaultFontLoading="FLASH_DE
FAULT_FONT_LOADING_NONE"
partialSubmit="false"
imageFormat="PNG_STAMPED"
inlineStyle="height:30px;"
value="#{row.Exc}"
svgFontEmbedding="SVG_FONT_EM
BEDDING_NONE"
graphicAntialiasing="false" specularHighlight="SH_OFF"
id="g2">
<dvt:topLabel position="LP_NONE"/>
<dvt:thresholdSet>
<dvt:threshold text="Low"
thresholdMaxValue="1"
fillColor="#ff0000"/>
<dvt:threshold text="Medium"
thresholdMaxValue="2"
fillColor="#00ff00"/>
<dvt:threshold text="High"
fillColor="#00ff00"/>
</dvt:thresholdSet>
</dvt:gauge>
</af:column>
---------------------------------------------------
42.可以把批處理、復選框批量選中代碼抽象出來 示例代碼如下
1頁面代碼
<af:column id="c470" headerText="選擇校驗"
align="center" width="50">
<af:selectBooleanCheckbox text="" label=""
id="sbc1" autoSubmit="true" valueChangeListener="#{impCos
tBean.selectHandler}">
<af:clientAttribute name="costId" value="#{row.Id}"/>
</af:selectBooleanCheckbox>
</af:column>
2impCostBean中
//得到保存選中的list
public List<Number> getSelectList(){
Map viewScope = ADFContext.getCurrent().getViewScope();
Object obj = viewScope.get("isSureSelectList");
if(obj==null){
obj=new ArrayList<Number>();
viewScope.put("isSureSelectList", obj);
}
return (List<Number>)obj;
}
//選中、退選處理
public void selectHandler(ValueChangeEvent valueChangeEvent) {
// Add event code here...
System.out.println("old
value:"+valueChangeEvent.getOldValue());
System.out.println("new value:"+valueChangeEvent.getNewValue());
Boolean old = (Boolean)valueChangeEvent.getOldValue();
Boolean newValue =
(Boolean)valueChangeEvent.getNewValue();
//排除這一情況null-->false
if (old == null && newValue.booleanValue() == false)
return;
Number id
=(Number)valueChangeEvent.getComponent().getAttributes().get("c
ostId");
if (!newValue.booleanValue()) {
if (getSelectList().contains(id)) {
System.out.println("放棄選擇:"+id);
getSelectList().remove(id);
}
} else {
System.out.println("選擇:"+id);
getSelectList().add(id);
}
System.out.println("當前選擇個數"+getSelectList().size());
}
}
以上不同頁面之間可以共用啊
以下是業務處理示例
處理1
//更新選擇的費用記錄的確定標志
public String sureHandler_action() {
List<Number> costIdList = getSelectList();
//1 檢查如果用戶什么都沒選
if(costIdList==null || costIdList.size()==0)
return null;
//2 檢查通過迭代處理
for(Number costId:getSelectList()){
...
}
//3 提交保存
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("Commit");
operationBinding.execute();
return null;
}
處理2 //cost 迭代更新cost的確定標志位
public void updateSureFlag(String voName,List<Number>
costIdList){
//先檢查參數
if(voName==null || "".equals(voName) || costIdList==null ||
costIdList.size()==0)
return;
//迭代更新
ViewObjectImpl vo =
(ViewObjectImpl)findViewObject(voName);
for(Number costId:costIdList){
Row[] byKey = vo.findByKey(new Key(new Object[]
{ costId }), 1);
if (byKey != null && byKey.length>0){
Row row=byKey[0];
row.setAttribute("Issure", '1');
}
}
this.getDBTransaction().commit();
}
------------------------------------------------------------
43.根據條件變顏色、底色三目表達式的運用 inlineStyle="background-color:#{(row.Canmerge == '1')?
((row.Ismother == '0')? 'yellow' : ''):''};"
-----------------------------------------------------------
44.自定義窗體彈出的兩種方式
popup
1頁面使用showPopupBehavior
<af:outputText value="outputText2" id="ot1">
<af:showPopupBehavior triggerType="mouseOver"
popupId="p2s"
align="afterStart"/>
</af:outputText>
<af:popup id="p2s">
<af:noteWindow id="wnw21" >
<f:verbatim>maoinmimewoovowvwvvowvm
sftrgregf</f:verbatim>
</af:noteWindow>
</af:popup>
2代碼 需要綁定popup到bean中
RichPopup onPopup = this.getOnPopup();
RichPopup.PopupHints hints = new RichPopup.PopupHints();
onPopup.show(hints);
------------------------------------------------------- 45.根據主鍵找記錄
ViewObject vo= this.getCdsUserView1();
Row[] byKey = vo.findByKey(new Key(new Object[]
{ costId }), 1);
if (byKey != null && byKey.length>0){
Row row=byKey[0];
for(String key:attrNames.keySet())
System.out.println(key+":"+row.getAttribute(key));
}
--------------------------------------------------------
46.組件相關
(1)通過組件上的事件獲取組件
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage messagge = new FacesMessage("Successfully
uploaded file"+file.getFilename()+"("+file.getLength()+"bytes)");
context.addMessage(event.getComponent().getClientId(context),mes
sage);
(2)獲取根組件
public static void addFacesErrorMessage(String attrName, String
msg){
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, attrName, msg);
ctx.addMessage(JSFUtils.getRootViewComponentId(), fm);
}
(3)通過根組件+組件ID查找組件
pubic static void addFacesErrorMessage(String attrName, String
msg){
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage fm = new
FacesMessage(FacesMessage.SEVERITY_ERROR, attrName, msg);
ctx.addMessage(JSFUtils.getRootViewComponentId().findCompone
nt("productpriceIT").getClientId(ctx), fm);
}
------------------------------------------------------
47.LOV頁面使用
1拖放view至頁面 選擇生成ADF Form 發現JobId的顯示組件
自動設置為ADF List of Values Input。如果選中Query List Automatically
彈出查詢頁面時 會直接顯示所有結果。
JobId為一個文本輸入框 旁邊有一個查詢按鈕 點擊后可以查詢 選
擇一條記錄 會返回到文本輸入框。注意 無論查詢顯示的是哪些字段
返回的都是 JobId。
2設置inputListOfValues組件的autoSubmit="true"。除了(3)的運
行效果之外 . 當輸入AD_ 按下Tab鍵 會彈出所有以AD_開頭的JobId選項。
. 當輸入AD_V 按下Tab鍵 會直接補全為AD_VP 因為只有一個值
滿足條件。
3為inputListOfValues組件增加autoSuggestBehavior 如
<af:autoSuggestBehavior
suggestedItems="#{bindings.JobId.suggestedItems}"/>此時 除了(4)
的運 行效果之外 會新增一種效果 隨着用戶的輸入 會自動下拉
顯示匹配的結果。經過測試 中文也可以支持自動匹配。
-----------------------------------------------------
48.添加表格的excel導出和打印功能
<f:facet name="menus">
<af:menu text="報表制作">
<af:commandMenuItem text="導出EXCEL">
<af:exportCollectionActionListener type="excelHTML"
exportedId="t1"/>
</af:commandMenuItem>
<af:commandMenuItem text="打印">
<af:showPrintablePageBehavior/>
</af:commandMenuItem>
</af:menu>
</f:facet>
----------------------------------------------------- 49.下拉列表的情況
Consignee==》null value
Consignee1==》0 索引
Transportation==》出口海運 value
Transportation1==》13 索引
Portofloading==》SHANGHAI value
Portofloading1==》114 索引
Pickupaddress==》5662 value
Pickupaddress1==》2 索引
貨代公司Forward==> Schenker value
貨代公司Forward1==> 4 索引

使用值變事件得到下拉列表的值時發現不能使用
ADFUtils.getBoundAttribute("");這個只能獲取值變前的值。
---------------------------------------------------
50.bean中得到當前行的高級使用
效果 點擊某個按鈕后傳入選中行的整個對象
方法 為該按鈕添加setActionListener其from值綁定到Table對應
iterator的currentRowto值綁定到頁面對應MB中ViewRowImpl類型
的變量rowObject(該變量就是用來接收傳進來的行對象的)。實例
<af:setActionListener from="#{bindings.tableIterator.currentRow}"
to="#{MB.rowObject}">,然后在rowObject的set方法中就可以設置行中字段值了。
--------------------------------------------------------
51.類oracle.jbo.server.ApplicationModuleImpl的一些方法
1executeCommand
public int executeCommand(java.lang.String command)
用於在服務器端執行特別的sql語句。返回值說明執行這條sql影響的
行數。該方法適用於測試和調試應用。
Specifies a valid SQL statement to be executed by the server. The
return integer value describes how many rows were affected by the
SQL statement. This is a utility method for testing and debugging
queries and applications.
The following code example uses executeCommand. The SQL string is
designed to update the EMP table. This example passes the string to
executeCommand, then prints a message to report how many rows
were actually updated.

public static void demoUpdateColumn(ApplicationModule appMod) {
String sqlStr = "UPDATE EMP " +
"SET MGR=7007 " +
"WHERE MGR=7698 ";

int n = appMod.getTransaction().executeCommand(sqlStr); System.out.println("Updated " + n + " rows.");
}

注意 這方法會執行任何可用的sql 比如說刪除數據庫中的一張表。
比較危險 慎用。
Be careful when using executeCommand, because it will execute any
valid SQL statement. For example, you could perform an operation like
the following DDL command:

appMod.getTransaction().executeCommand("DROP TABLE
MYTEMPTABLE");

A pending database transaction could be committed inadvertently due
to the implicit commit performed by DDL operations, as well as having
any row locks released.


Parameters:
command - a valid SQL statement.

--------------------------------------------------------------------------------
2getDBTransaction public DBTransaction getDBTransaction()
得到當前這個am的事務不同am的事務不共享。
Gets this Application Module's database transaction. Note that if this
method is invoked on a nested Application Module, the root
Application Module's transaction is returned. This is because the
transaction is shared by all Application Modules contained by the root
Application Module.
If the user creates two root Application Modules, they normally do not
share the transaction. To share a transaction acroos root Application
Modules, the user would need to define a global transaction through
JTA and have both Application Modules participate in it.

Returns:
the transaction.
Throws:
java.lang.IllegalStateException - if no root Application Module is found.
This could happen if the user calls this method on an Application
Module that has

--------------------------------------------------------------------------------
52.實體中的屬性之歷史屬性和可更新的和刷新
1.History Column
Select this checkbox to log changes to the database. You can only log
changes if: You have implemented authorization (login) using
JAAS/JAZN. The selected attribute is persistent. Changes will be
logged in the corresponding database column. You have not selected
Primary Key, Mandatory, or Discriminator. The attribute type is Char,
Character, String, Date, Timestamp, or Number.

Once you have selected this checkbox, choose the history column type:
1created on 創建時間
Select this option to use the column to log the date on which the row
was first created. The attribute type must be Date or Timestamp.
2modified on 修改時間
Select this option to use the column to log the date on which the row
was last modified. The attribute type must be Date or Timestamp.
3created by 誰創建的
Select this option to use the column to log the user who created the
row. The attribute type must be Char, Character, or String.
4modified by 誰修改的
Select this option to use the column to log the user who last modified
the row. The attribute type must be Char, Character, or String.
5version number Select this option to use this column to log the number of times the
row has been changed. The attribute type must be Number.

2.Updateable
The view attribute setting is based on the entity attribute setting and
can made more restrictive.

2Always
Select to make an attribute updatable.

3While New
Select to make an attribute updatable before an entity is first posted.

4Never
Select to make an attribute read-only.

3.Refresh After
Select one or both of these options to reflect the effects of triggers
after DML operations.

1update
After the entity object posts changes to an existing database row, the entity object retrieves the value of the attribute from the
corresponding database field.

2Insert After
the entity object inserts a new row in the database, the entity object
retrieves the value of this attribute fromhe corresponding database
field
----------------------------------------------------------------
53.ADF自帶過濾功能不區分大小寫敏感不敏感
caseInsensitive
caseSensitive

filterFeatures="caseInsensitive"
例子如下
<af:column sortProperty="Consignee" filterable="true"
sortable="true"
headerText="#{bindings.CdsExportApplyVie
w1.hints.Consignee.label}"
id="c35" filterFeatures="caseInsensitive">
---------------------------------------------------------------
54.將當前行的DepartmentId放入pageFlowScope中;
CollectionModel model = (CollectionModel) employeeTable.getValue();
JUCtrlHierBinding tableBinding = (JUCtrlHierBinding)
model.getWrappedData();
//table synchronizes row selection with current binding row
DCIteratorBinding tableIterator =
tableBinding.getDCIteratorBinding();
if (tableIterator.getCurrentRow() != null) {
Object departmentIdValue =
tableIterator.getCurrentRow().getAttribute("DepartmentI
d");
//copy value into the pageFlowScope, which is returned in an
task
//flow param output
ADFContext adfCtx = ADFContext.getCurrent();
Map pageFlowScope = adfCtx.getPageFlowScope();
pageFlowScope.put("departmentId", departmentIdValue);
}
----------------------------------------------------------------
55.玩輸出模式
<af:column id="c201" headerText="操作"
width="105"
rendered="#{adfFacesContext.outputMode!='printable'}">
<af:commandButton text="財務退回"
id="cb11"
binding="#{tuiDanBean.vflistBa
ckBtn}"
action="#{tuiDanBean.vflistBac
k_action}"
disabled="#{row.Vfdate!=null}
"/>
</af:column>
<af:activeImage source="/images/stockChart.gif"
rendered="#{adfFacesContext.outputMode != "email"}"/>
--------------------------------------------------------------
56.轉向問題看官方最佳解說
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session =
(HttpSession)context.getExternalContext().getSession(tru
e);//session不可能為空
String actionStr =
String.valueOf(session.getAttribute("firstLink"));
context.getApplication().getNavigationHandler().handleNavi
gation(context, null, actionStr);
How-to efficiently redirect an ADF Faces view using ADFc
ADF Faces developers use
facesContex.getExternalContext().redirect(String) to issue a GET
request to a
JSF view. Using ADFc, the redirect URL should neither be read from
the current UIView root directly or
provided in the form /faces/<viewId name>. Instead, have the
controller generating the redirect String
for a specific viewId as shown below:
FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();

String viewId = "... add viewId...."
ControllerContext controllerCtx = null;
controllerCtx = ControllerContext.getInstance();
String activityURL = controllerCtx.getGlobalViewActivityURL(viewId);
try{
ectx.redirect(activityURL);
} catch (IOException e) {
//Can't redirect
e.printStackTrace(); }

Why? Because a redirect is a Get request and you don't want ADFc to
treat it as a new application request
but instead retrieve the internal controller state. For this you need the
state toke in the redirect URL,
which is what the code line above does
----------------------------------------------------------------
57.bean中增加組件
UIComponent parent =....;
RichInputText it = new RichInputText();

it.setValue("test...");parent.getChildren().add(it);
---------------------------------------------------------------
58.刪除確認對話框
1popup所在頁面位置
<f:view>
<af:document id="d1" title="成品計划員管理">
<af:messages id="m1"/>
<af:form id="f1">
<!-- 對話框 開始 -->
<af:popup id="p1"> ...
2popup示例只需要改這個dialogListener
<af:popup id="p1">
<af:dialog id="d5" title="刪除確認"
dialogListener="#{consigneeBean.deleteApply}">
<af:panelGroupLayout id="pg210" halign="center"
layout="vertical">
<br/>
<af:outputText value="確定要刪除嗎 "
id="ot341"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br/>
</af:panelGroupLayout>
</af:dialog>
</af:popup>
3調用者
<af:commandToolbarButton text="刪除" id="ctb4">
<af:showPopupBehavior triggerType="click"
popupId=":::p1"/>
</af:commandToolbarButton>
-------------------------------------------------------------
59.常用工具類小結
1org.apache.commons.lang.math.NumberUtils 處理數字與字符串
的無異常轉化
例子
String str=null;
int i = NumberUtils.toInt(str);
System.out.println("i="+i);
字符串是null 或是其他任意不能轉化成整數的字符串 都會轉變成0。
2java.text.SimpleDateFormat 用於格式化日期
3java.text.DecimalFormat 用於格式化數字

---------------------------------------------------------------
60.將文件作為流讀入內存

        InputStream input = ClassLoaderUtil.getStream("sap.properties");
        prop.load(input);
        input.close();

        InputStream is = InitialLoader.class.getResourceAsStream("/global.properties");


61.點一下按鈕關閉當前頁面

1         FacesContext fc = FacesContext.getCurrentInstance();
2         ExtendedRenderKitService erks =
3             (ExtendedRenderKitService) Service.getRenderKitService(fc, ExtendedRenderKitService.class);
4 
5         erks.addScript(fc, "window.close();");

 

 

62.設置日期為當前日期

如果eo中對應的屬性類型為oracle.jbo.domain.Date有以下兩種設置
為當前日期方式

 

        row.setAttribute("Applydate", new oracle.jbo.domain.Date(oracle.jbo.domain.Date.getCurrentDate()));

        oracle.jbo.domain.Date now = new oracle.jbo.domain.Date(new Timestamp(System.currentTimeMillis()));


63.對數據庫的操作要謹慎一些有提交就會有回滾善用異常

Example 4–15 Updating an Existing Entity Row

 1     /* Update the status of an existing order */
 2     public void updateOrderStatus(long orderId, String newStatus) {
 3         //1. Find the order OrderEOImpl order = retrieveOrderById(orderId);
 4         if (order != null) {
 5             //2. Set its Status attribute to a new value
 6             order.setOrderStatusCode(newStatus);
 7             //3. Commit the transaction
 8             try {
 9                 getDBTransaction().commit();
10             } catch (JboException ex) {
11                 getDBTransaction().rollback();
12                 throw ex;
13             }
14         }
15     }

The example for removing an entity row would be the same, except that after finding the existing entity, you would use the following line instead to remove 

the entity before committing the transaction:
// Remove the entity instead!
order.remove();

64.官方查詢標准步驟:
1.Request begings and application module is acquired
2.setWhereClause(null) 清除查詢提交
3.setWhereClauseParam(null) 清除查詢綁定變量
4.setWhereWhereClause(...)
5.setWhereClauseParam(...)
6.executeQuery()
7.Application module is released


65.建立View Criteria 查詢條件查詢

 1 import oracle.jbo.ApplicationModule;
 2 import oracle.jbo.Row;
 3 import oracle.jbo.ViewCriteria;
 4 import oracle.jbo.ViewCriteriaRow;
 5 import oracle.jbo.ViewObject;
 6 import oracle.jbo.client.Configuration;
 7 
 8 public class TestClientViewCriteria {
 9     public static void main(String[] args) {
10         String amDef = "devguide.examples.readonlyvo.PersonService";
11         String config = "PersonServiceLocal";
12         ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
13         // 1. Find the view object to filter
14         ViewObject vo = am.findViewObject("PersonList");
15         // Work with your appmodule and view object here
16         Configuration.releaseRootApplicationModule(am, true);
17         // 2. Create a view criteria row set for this view object
18         ViewCriteria vc = vo.createViewCriteria();
19         // 3. Use the view criteria to create one or more view criteria rows
20         ViewCriteriaRow vcr1 = vc.createViewCriteriaRow();
21         ViewCriteriaRow vcr2 = vc.createViewCriteriaRow();
22         // 4. Set attribute values to filter on in appropriate view criteria rows
23         vcr1.setAttribute("PersonId", "> 200");
24         vcr1.setAttribute("Email", "d%");
25         vcr1.setAttribute("PersonTypeCode", "STAFF");
26         // Note the IN operator must be followed by a space after the operator.
27         vcr2.setAttribute("PersonId", "IN (204,206)");
28         vcr2.setAttribute("LastName", "Hemant"); // 5. Add the view criteria rows to the view critera row set
29         vc.add(vcr1);
30         vc.add(vcr2);
31         // 6. Apply the view criteria to the view object
32         vo.applyViewCriteria(vc);
33         // 7. Execute the query
34         vo.executeQuery();
35         while (vo.hasNext()) {
36             Row curPerson = vo.next();
37             System.out.println(curPerson.getAttribute("PersonId") + "" + curPerson.getAttribute("Email"));
38         }
39     }
40 }

 


66.使用VO創建新行

 1 import oracle.jbo.ApplicationModule;
 2 import oracle.jbo.Row;
 3 import oracle.jbo.ViewObject;
 4 import oracle.jbo.client.Configuration;
 5 import oracle.jbo.domain.DBSequence;
 6 import oracle.jbo.domain.Date;
 7 import oracle.jbo.domain.Timestamp;
 8 
 9 public class TestCreateOrder {
10     public static void main(String[] args) throws Throwable {
11         String amDef = "oracle.fodemo.storefront.store.service.StoreServiceAM";
12         String config = "StoreServiceAMLocal";
13         ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
14         // 1. Find the Orders view object instance.
15         ViewObject orders = am.findViewObject("Orders");
16         // 2. Create a new row and insert it into the row set
17         Row newOrder = orders.createRow();
18         orders.insertRow(newOrder);
19         // Show the entity object-related defaulting for CreatedBy
20         System.out.println("CreatedBy defaults to: " + newOrder.getAttribute("CreatedBy"));
21         // 3. Set values for some of the required attributes
22         Date now = new Date(new Timestamp(System.currentTimeMillis()));
23         newOrder.setAttribute("OrderDate", now);
24         newOrder.setAttribute("OrderStatusCode", "PENDING");
25         newOrder.setAttribute("OrderTotal", 500);
26         newOrder.setAttribute("CustomerId", 110);
27         newOrder.setAttribute("ShipToAddressId", 2);
28         newOrder.setAttribute("ShippingOptionId", 2);
29         newOrder.setAttribute("FreeShippingFlag", "N");
30         newOrder.setAttribute("GiftwrapFlag", "N");
31         // 4. Commit the transaction
32         am.getTransaction().commit();
33         // 5. Retrieve and display the trigger-assigned order id
34         DBSequence id = (DBSequence) newOrder.getAttribute("OrderId");
35         System.out.println("Thanks, reference number is " + id.getSequenceNumber());
36         Configuration.releaseRootApplicationModule(am, true);
37     }
38 }

 

67.得到sequence

 1     public oracle.jbo.domain.Number getSequenceNumber() {
 2         try {
 3             String seq = "your_db_sequence_name";
 4             oracle.jbo.server.SequenceImpl theSeq = new oracle.jbo.server.SequenceImpl(seq, getDBTransaction());
 5             oracle.jbo.domain.Number seqNextNumber = theSeq.getSequenceNumber();
 6             return seqNextNumber;
 7         } catch (Exception e) {
 8             //handle exceptions
 9         }
10         return null;
11     }

綁定方法到頁面上之后在bean中調用

1     public oracle.jbo.domain.Number getNextEmployeeSequenceNumber() {
2         BindingContext bindingContext = BindingContext.getCurrent();
3         BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
4         OperationBinding getNextSequence = bindings.getOperationBinding("getSequenceNumber");
5         oracle.jbo.domain.Number seqVal = (oracle.jbo.domain.Number) getNextSequence.execute();
6         return seqVal;
7     }

 程序員的基礎教程:菜鳥程序員


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM