Oracle ADF 11g后台常用方法(2)
来源:互联网 发布:社交网络 肖恩帕克 编辑:程序博客网 时间:2024/06/08 13:33
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(); } }
0 0
- Oracle ADF 11g后台常用方法(2)
- Oracle ADF 11g后台常用方法(1)
- Oracle ADF常用快捷键
- adf常用方法总结
- ADF一些常用方法
- adf常用方法总结
- 关于Oracle ADF 11g实现自动提示(客户端和服务端监听的使用)(一)
- 关于Oracle ADF 11g的传值给bounded task flow(二)
- 关于Oracle ADF 11g的VO处理
- Oracle ADF Faces 10g 简介
- ADF Mobile 11g 架构
- ADF 11g: 选择ADF table中的所有行
- 关于Oracle ADF 11g的客户端和服务端监听的使用(二)
- 关于Oracle ADF 11g的传值给bounded task flow
- Oracle ADF VO常用的API
- ORACLE 11G卸载方法
- Oracle 11g 卸载方法
- Oracle 11g+删除方法
- picasso的简单用法
- 为什么在项目中使用Using namespace CocosDenshion;会提示出错expected namespace namespace
- 背景建模--高斯混合模型
- Picasso入门教程(九)回调,remoteViews,通知
- 第十五周项目—阅读程序(3)
- Oracle ADF 11g后台常用方法(2)
- POJ3187——Backward Digit Sums
- SASS语法学习
- debian7 修改系统时间
- xml解析方式
- 手机软件项目管理7—三方应用导入流程
- (Math)矩阵求导
- C++第十五周实践项目2————洗牌
- NYOJ 469 擅长排列的小明 II