1.获取request
public HttpServletRequest getHttpRequest() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)context.getExternalContext().getRequest();
return request;
}
2.后台获取树结构点击行的方法
public void selectSendPerson(SelectionEvent selectionEvent){
Map viewScope = AdfFacesContext.getCurrentInstance().getViewScope();
RichTree tree = (RichTree)selectionEvent.getSource();
CollectionModel model = (CollectionModel)tree.getValue();
JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
String methodExpression = "#{bindings." + treeBinding.getName() + ".treeModel.makeCurrent}";
this.handleTreeSelection(selectionEvent, methodExpression);
RowKeySet rks = selectionEvent.getAddedSet();
Iterator iterator = rks.iterator();
if (iterator.hasNext()) {
List rowKey = (List)iterator.next();
JUCtrlHierNodeBinding node = treeBinding.findNodeByKeyPath(rowKey);
JUCtrlHierTypeBinding nodeType = node.getHierTypeBinding();
Row rw = node.getRow();
Object leaf = rw.getAttribute("LeafNode");
}
}
private void handleTreeSelection(SelectionEvent selectionEvent, String el) {
FacesContext fctx = FacesContext.getCurrentInstance();
ELContext elctx = fctx.getELContext();
ExpressionFactory exprFactory = fctx.getApplication().getExpressionFactory();
MethodExpression me =
exprFactory.createMethodExpression(elctx, el, Object.class, new Class[] { SelectionEvent.class });
me.invoke(elctx, new Object[] { selectionEvent });
}
3.后台获取face-config.xml中的配置信息并跳转
public void navToOutCome(String outCome) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
NavigationHandler navigationHandler = application.getNavigationHandler();
ControllerContext controllerContext = ControllerContext.getInstance();
String viewId = controllerContext.getCurrentViewPort().getViewId();
if (viewId != null) {
navigationHandler.handleNavigation(facesContext, viewId, outCome);
}
}
4.ADF的scope获取方式
ADFContext.getCurrent().getApplicationScope();
ADFContext.getCurrent().getSessionScope();
AdfFacesContext.getCurrentInstance().getPageFlowScope();
ADFContext.getCurrent().getRequestScope();
ADFContext.getCurrent().getViewScope();
5.11g弹框
<af:popup childCreation="deferred" autoCancel="disabled" id="p2" binding="#{testBean.pop}" contentDelivery="immediate">
<af:dialog id="d2" type="ok" closeIconVisible="false">
<f:facet name="buttonBar"/>
<af:panelGroupLayout id="pgl3" layout="scroll" halign="center" inlineStyle="width:160px;height:60px">
<p>
<h:outputText id="ot3" binding="#{TaskApproveBean.outmessage}" value="NULL"/>
</p>
</af:panelGroupLayout>
</af:dialog>
</af:popup>
private RichPopup pop;
private HtmlOutputText outmessage = new HtmlOutputText();
public void showPop(String message) {
this.outmessage.setValue(message);
this.pop.show(new RichPopup.PopupHints());
}
6.弹出提示框
public void showInfoMessage(String Msg) {
FacesMessage m = new FacesMessage();
m.setDetail(Msg);
m.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext.getCurrentInstance().addMessage(null, m);
}
7.页面布局常用的标签
<af:panelGroupLayout id="pgl1"/> <!--一片区域类是div 有水平和垂直 -->
<af:panelFormLayout id="p2" /> <!--自动排列form表单元素 -->
<af:panelGridLayout id="p3" /> <!--表格布局 -->
8.点击页面按钮在当前按钮坐标弹出选值框
<af:inputText id="USERCODE" columns="40" label="人员编码" disabled="true" contentStyle="width:500px;" inding="#{testBean.bdUserCode}"/>
<af:commandLink id="c2" >
<af:image id="i3" source="../images/search.png"/>
<af:showPopupBehavior popupId="myPopup" triggerType="action" align="endBefore" alignId="c2" />
</af:commandLink>
<af:popup id="myPopup" launcherVar="source" contentDelivery="lazyUncached"
eventContext="launcher" binding="#{testBean.windowPopUp}" popupFetchListener="#{testBean.winPopFechListener}">
</af:popup>
ClientListenerSet set = new ClientListenerSet();
set.addBehavior("new AdfShowPopupBehavior('myPopup',AdfRichPopup.ALIGN_AFTER_END,null,'focus')");
9.eo中添加create方法在执行#{binding.create.execute}自动执行初始化序列
protected void create(AttributeList attributeList) {
super.create(attributeList);
SequenceImpl s = new SequenceImpl("TEST_SEQ", this.getDBTransaction());
Long next = (Long)s.getData();
try{
this.setId(next.toString());
}catch(Exception e){
e.printStackTrace();
}
}
10.oracle.jbo.RowInconsistentException: JBO-25014: 其他用户已更改具有主键 oracle.jbo.Key[2332] 的行。
异常解决方法:在EOImpl中加入以下代码
public void lock() {
try {
super.lock();
} catch (RowInconsistentException e) {
e.printStackTrace();
refresh(REFRESH_WITH_DB_ONLY_IF_UNCHANGED | REFRESH_CONTAINEES);
System.out.println("已被处理的异常信息:"+new java.util.Date().toLocaleString()+" 更新时出现锁异常!");
super.lock();
}
}