adf笔记
1>jsf页面js调试,手动添加debugger调试
方案:在页面中添加debugger,然后打开“开发者工具”(必须打开),直接运行页面自动跳转到debugger处。
2>jdeveloper使用svn版本控制,修改后版本控制异常
方案:使用jdeveloper集成的svn版本进行控制,经常出现版本控制异常,比如修改了几个问题,查看版本变动的时候
发现以前添加的文件都没有版本了,方法重新启动jdeveloper
3>jdeveloper使用svn版本控制,修改文件后查看挂起的更改,发现没有记录
方案:打开任意一个jdeveloper中的项目,然后再查看挂起的更改。
4>jdeveloper开发过程中,调试和运行可能突然中断,然后点击页面运行或调试,进入页面后直接卡死,紧接着weblogic直接终止运行或调试。
再次运行或是调试,weblgici始终无法启动,
方案:run>start server instance,先运行weblogci,然后再选择页面点击运行
5>无法验证事务处理中的所有行
运行项目报错:
javax.faces.el.EvaluationException: oracle.jbo.TxnValException: JBO-27023: 无法验证事务处理中的所有行。
出错原因:提交的字段的值没有通过验证
比如说:字段的长度过长,类型不匹配
注意:如果对数据库中的字段做修改,要与eo同步更改。
6>jdeveloper快捷键
ctrl+enter:输入sop然后按ctrl+enter,输出 System.out.println()
ctrl+enter:直接输入ctrl+enter,出来流程控制的智能提示
ctrl+j:删除本行
shift+enter:换行
ctrl+shift+上下方向键:向上或向下移动当前行代码
ctrl+shift+空格键:上下文智能提示
shift+alt+f:格式化
7>通用类ADFUtils和JSFUtils
- package view;
- import java.util.ArrayList;
- import java.util.List;
- import javax.faces.model.SelectItem;
- import oracle.adf.model.BindingContext;
- import oracle.adf.model.binding.DCBindingContainer;
- import oracle.adf.model.binding.DCIteratorBinding;
- import oracle.adf.model.binding.DCParameter;
- import oracle.adf.share.logging.ADFLogger;
- import oracle.binding.AttributeBinding;
- import oracle.binding.BindingContainer;
- import oracle.binding.ControlBinding;
- import oracle.binding.OperationBinding;
- import oracle.jbo.ApplicationModule;
- import oracle.jbo.Key;
- import oracle.jbo.Row;
- import oracle.jbo.uicli.binding.JUCtrlValueBinding;
- /**
- * A series of convenience functions for dealing with ADF Bindings.
- * Note: Updated for JDeveloper 11
- *
- * @author Duncan Mills
- * @author Steve Muench
- *
- * $Id: ADFUtils.java 2513 2007-09-20 20:39:13Z ralsmith $.
- */
- public class ADFUtils {
- public static final ADFLogger LOGGER = ADFLogger.createADFLogger(ADFUtils.class);
- /**
- * Get application module for an application module data control by name.
- * @param name application module data control name
- * @return ApplicationModule
- */
- public static ApplicationModule getApplicationModuleForDataControl(String name) {
- return (ApplicationModule)JSFUtils.resolveExpression("#{data." + name +
- ".dataProvider}");
- }
- /**
- * A convenience method for getting the value of a bound attribute in the
- * current page context programatically.
- * @param attributeName of the bound value in the pageDef
- * @return value of the attribute
- */
- public static Object getBoundAttributeValue(String attributeName) {
- return findControlBinding(attributeName).getInputValue();
- }
- /**
- * A convenience method for setting the value of a bound attribute in the
- * context of the current page.
- * @param attributeName of the bound value in the pageDef
- * @param value to set
- */
- public static void setBoundAttributeValue(String attributeName,
- Object value) {
- findControlBinding(attributeName).setInputValue(value);
- }
- /**
- * Returns the evaluated value of a pageDef parameter.
- * @param pageDefName reference to the page definition file of the page with the parameter
- * @param parameterName name of the pagedef parameter
- * @return evaluated value of the parameter as a String
- */
- public static Object getPageDefParameterValue(String pageDefName,
- String parameterName) {
- BindingContainer bindings = findBindingContainer(pageDefName);
- DCParameter param =
- ((DCBindingContainer)bindings).findParameter(parameterName);
- return param.getValue();
- }
- /**
- * Convenience method to find a DCControlBinding as an AttributeBinding
- * to get able to then call getInputValue() or setInputValue() on it.
- * @param bindingContainer binding container
- * @param attributeName name of the attribute binding.
- * @return the control value binding with the name passed in.
- *
- */
- public static AttributeBinding findControlBinding(BindingContainer bindingContainer,
- String attributeName) {
- if (attributeName != null) {
- if (bindingContainer != null) {
- ControlBinding ctrlBinding =
- bindingContainer.getControlBinding(attributeName);
- if (ctrlBinding instanceof AttributeBinding) {
- return (AttributeBinding)ctrlBinding;
- }
- }
- }
- return null;
- }
- /**
- * Convenience method to find a DCControlBinding as a JUCtrlValueBinding
- * to get able to then call getInputValue() or setInputValue() on it.
- * @param attributeName name of the attribute binding.
- * @return the control value binding with the name passed in.
- *
- */
- public static AttributeBinding findControlBinding(String attributeName) {
- return findControlBinding(getBindingContainer(), attributeName);
- }
- /**
- * Return the current page's binding container.
- * @return the current page's binding container
- */
- public static BindingContainer getBindingContainer() {
- return (BindingContainer)JSFUtils.resolveExpression("#{bindings}");
- }
- /**
- * Return the Binding Container as a DCBindingContainer.
- * @return current binding container as a DCBindingContainer
- */
- public static DCBindingContainer getDCBindingContainer() {
- return (DCBindingContainer)getBindingContainer();
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding.
- *
- * Uses the value of the 'valueAttrName' attribute as the key for
- * the SelectItem key.
- *
- * @param iteratorName ADF iterator binding name
- * @param valueAttrName name of the value attribute to use
- * @param displayAttrName name of the attribute from iterator rows to display
- * @return ADF Faces SelectItem for an iterator binding
- */
- public static List<SelectItem> selectItemsForIterator(String iteratorName,
- String valueAttrName,
- String displayAttrName) {
- return selectItemsForIterator(findIterator(iteratorName),
- valueAttrName, displayAttrName);
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding with description.
- *
- * Uses the value of the 'valueAttrName' attribute as the key for
- * the SelectItem key.
- *
- * @param iteratorName ADF iterator binding name
- * @param valueAttrName name of the value attribute to use
- * @param displayAttrName name of the attribute from iterator rows to display
- * @param descriptionAttrName name of the attribute to use for description
- * @return ADF Faces SelectItem for an iterator binding with description
- */
- public static List<SelectItem> selectItemsForIterator(String iteratorName,
- String valueAttrName,
- String displayAttrName,
- String descriptionAttrName) {
- return selectItemsForIterator(findIterator(iteratorName),
- valueAttrName, displayAttrName,
- descriptionAttrName);
- }
- /**
- * Get List of attribute values for an iterator.
- * @param iteratorName ADF iterator binding name
- * @param valueAttrName value attribute to use
- * @return List of attribute values for an iterator
- */
- public static List attributeListForIterator(String iteratorName,
- String valueAttrName) {
- return attributeListForIterator(findIterator(iteratorName),
- valueAttrName);
- }
- /**
- * Get List of Key objects for rows in an iterator.
- * @param iteratorName iterabot binding name
- * @return List of Key objects for rows
- */
- public static List<Key> keyListForIterator(String iteratorName) {
- return keyListForIterator(findIterator(iteratorName));
- }
- /**
- * Get List of Key objects for rows in an iterator.
- * @param iter iterator binding
- * @return List of Key objects for rows
- */
- public static List<Key> keyListForIterator(DCIteratorBinding iter) {
- List<Key> attributeList = new ArrayList<Key>();
- for (Row r : iter.getAllRowsInRange()) {
- attributeList.add(r.getKey());
- }
- return attributeList;
- }
- /**
- * Get List of Key objects for rows in an iterator using key attribute.
- * @param iteratorName iterator binding name
- * @param keyAttrName name of key attribute to use
- * @return List of Key objects for rows
- */
- public static List<Key> keyAttrListForIterator(String iteratorName,
- String keyAttrName) {
- return keyAttrListForIterator(findIterator(iteratorName), keyAttrName);
- }
- /**
- * Get List of Key objects for rows in an iterator using key attribute.
- *
- * @param iter iterator binding
- * @param keyAttrName name of key attribute to use
- * @return List of Key objects for rows
- */
- public static List<Key> keyAttrListForIterator(DCIteratorBinding iter,
- String keyAttrName) {
- List<Key> attributeList = new ArrayList<Key>();
- for (Row r : iter.getAllRowsInRange()) {
- attributeList.add(new Key(new Object[] { r.getAttribute(keyAttrName) }));
- }
- return attributeList;
- }
- /**
- * Get a List of attribute values for an iterator.
- *
- * @param iter iterator binding
- * @param valueAttrName name of value attribute to use
- * @return List of attribute values
- */
- public static List attributeListForIterator(DCIteratorBinding iter,
- String valueAttrName) {
- List attributeList = new ArrayList();
- for (Row r : iter.getAllRowsInRange()) {
- attributeList.add(r.getAttribute(valueAttrName));
- }
- return attributeList;
- }
- /**
- * Find an iterator binding in the current binding container by name.
- *
- * @param name iterator binding name
- * @return iterator binding
- */
- public static DCIteratorBinding findIterator(String name) {
- DCIteratorBinding iter =
- getDCBindingContainer().findIteratorBinding(name);
- if (iter == null) {
- throw new RuntimeException("Iterator '" + name + "' not found");
- }
- return iter;
- }
- /**
- * @param bindingContainer
- * @param iterator
- * @return
- */
- public static DCIteratorBinding findIterator(String bindingContainer, String iterator) {
- DCBindingContainer bindings =
- (DCBindingContainer)JSFUtils.resolveExpression("#{" + bindingContainer + "}");
- if (bindings == null) {
- throw new RuntimeException("Binding container '" +
- bindingContainer + "' not found");
- }
- DCIteratorBinding iter = bindings.findIteratorBinding(iterator);
- if (iter == null) {
- throw new RuntimeException("Iterator '" + iterator + "' not found");
- }
- return iter;
- }
- /**
- * @param name
- * @return
- */
- public static JUCtrlValueBinding findCtrlBinding(String name){
- JUCtrlValueBinding rowBinding =
- (JUCtrlValueBinding)getDCBindingContainer().findCtrlBinding(name);
- if (rowBinding == null) {
- throw new RuntimeException("CtrlBinding " + name + "' not found");
- }
- return rowBinding;
- }
- /**
- * Find an operation binding in the current binding container by name.
- *
- * @param name operation binding name
- * @return operation binding
- */
- public static OperationBinding findOperation(String name) {
- OperationBinding op =
- getDCBindingContainer().getOperationBinding(name);
- if (op == null) {
- throw new RuntimeException("Operation '" + name + "' not found");
- }
- return op;
- }
- /**
- * Find an operation binding in the current binding container by name.
- *
- * @param bindingContianer binding container name
- * @param opName operation binding name
- * @return operation binding
- */
- public static OperationBinding findOperation(String bindingContianer,
- String opName) {
- DCBindingContainer bindings =
- (DCBindingContainer)JSFUtils.resolveExpression("#{" + bindingContianer + "}");
- if (bindings == null) {
- throw new RuntimeException("Binding container '" +
- bindingContianer + "' not found");
- }
- OperationBinding op =
- bindings.getOperationBinding(opName);
- if (op == null) {
- throw new RuntimeException("Operation '" + opName + "' not found");
- }
- return op;
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding with description.
- *
- * Uses the value of the 'valueAttrName' attribute as the key for
- * the SelectItem key.
- *
- * @param iter ADF iterator binding
- * @param valueAttrName name of value attribute to use for key
- * @param displayAttrName name of the attribute from iterator rows to display
- * @param descriptionAttrName name of the attribute for description
- * @return ADF Faces SelectItem for an iterator binding with description
- */
- public static List<SelectItem> selectItemsForIterator(DCIteratorBinding iter,
- String valueAttrName,
- String displayAttrName,
- String descriptionAttrName) {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- for (Row r : iter.getAllRowsInRange()) {
- selectItems.add(new SelectItem(r.getAttribute(valueAttrName),
- (String)r.getAttribute(displayAttrName),
- (String)r.getAttribute(descriptionAttrName)));
- }
- return selectItems;
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding.
- *
- * Uses the value of the 'valueAttrName' attribute as the key for
- * the SelectItem key.
- *
- * @param iter ADF iterator binding
- * @param valueAttrName name of value attribute to use for key
- * @param displayAttrName name of the attribute from iterator rows to display
- * @return ADF Faces SelectItem for an iterator binding
- */
- public static List<SelectItem> selectItemsForIterator(DCIteratorBinding iter,
- String valueAttrName,
- String displayAttrName) {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- for (Row r : iter.getAllRowsInRange()) {
- selectItems.add(new SelectItem(r.getAttribute(valueAttrName),
- (String)r.getAttribute(displayAttrName)));
- }
- return selectItems;
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding.
- *
- * Uses the rowKey of each row as the SelectItem key.
- *
- * @param iteratorName ADF iterator binding name
- * @param displayAttrName name of the attribute from iterator rows to display
- * @return ADF Faces SelectItem for an iterator binding
- */
- public static List<SelectItem> selectItemsByKeyForIterator(String iteratorName,
- String displayAttrName) {
- return selectItemsByKeyForIterator(findIterator(iteratorName),
- displayAttrName);
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding with discription.
- *
- * Uses the rowKey of each row as the SelectItem key.
- *
- * @param iteratorName ADF iterator binding name
- * @param displayAttrName name of the attribute from iterator rows to display
- * @param descriptionAttrName name of the attribute for description
- * @return ADF Faces SelectItem for an iterator binding with discription
- */
- public static List<SelectItem> selectItemsByKeyForIterator(String iteratorName,
- String displayAttrName,
- String descriptionAttrName) {
- return selectItemsByKeyForIterator(findIterator(iteratorName),
- displayAttrName,
- descriptionAttrName);
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding with discription.
- *
- * Uses the rowKey of each row as the SelectItem key.
- *
- * @param iter ADF iterator binding
- * @param displayAttrName name of the attribute from iterator rows to display
- * @param descriptionAttrName name of the attribute for description
- * @return ADF Faces SelectItem for an iterator binding with discription
- */
- public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding iter,
- String displayAttrName,
- String descriptionAttrName) {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- for (Row r : iter.getAllRowsInRange()) {
- selectItems.add(new SelectItem(r.getKey(),
- (String)r.getAttribute(displayAttrName),
- (String)r.getAttribute(descriptionAttrName)));
- }
- return selectItems;
- }
- /**
- * Get List of ADF Faces SelectItem for an iterator binding.
- *
- * Uses the rowKey of each row as the SelectItem key.
- *
- * @param iter ADF iterator binding
- * @param displayAttrName name of the attribute from iterator rows to display
- * @return List of ADF Faces SelectItem for an iterator binding
- */
- public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding iter,
- String displayAttrName) {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- for (Row r : iter.getAllRowsInRange()) {
- selectItems.add(new SelectItem(r.getKey(),
- (String)r.getAttribute(displayAttrName)));
- }
- return selectItems;
- }
- /**
- * Find the BindingContainer for a page definition by name.
- *
- * Typically used to refer eagerly to page definition parameters. It is
- * not best practice to reference or set bindings in binding containers
- * that are not the one for the current page.
- *
- * @param pageDefName name of the page defintion XML file to use
- * @return BindingContainer ref for the named definition
- */
- private static BindingContainer findBindingContainer(String pageDefName) {
- BindingContext bctx = getDCBindingContainer().getBindingContext();
- BindingContainer foundContainer =
- bctx.findBindingContainer(pageDefName);
- return foundContainer;
- }
- /**
- * @param opList
- */
- public static void printOperationBindingExceptions(List opList){
- if(opList != null && !opList.isEmpty()){
- for(Object error:opList){
- LOGGER.severe( error.toString() );
- }
- }
- }
- }
ADFUtils
- package view;
- import java.util.Iterator;
- import java.util.Locale;
- import java.util.Map;
- import java.util.MissingResourceException;
- import java.util.ResourceBundle;
- import javax.el.ELContext;
- import javax.el.ExpressionFactory;
- import javax.el.MethodExpression;
- import javax.el.ValueExpression;
- import javax.faces.application.Application;
- import javax.faces.application.FacesMessage;
- import javax.faces.component.UIComponent;
- import javax.faces.component.UIViewRoot;
- import javax.faces.context.ExternalContext;
- import javax.faces.context.FacesContext;
- import javax.servlet.http.HttpServletRequest;
- /**
- * General useful static utilies for working with JSF.
- * NOTE: Updated to use JSF 1.2 ExpressionFactory.
- *
- * @author Duncan Mills
- * @author Steve Muench
- *
- * $Id: JSFUtils.java 1885 2007-06-26 00:47:41Z ralsmith $
- */
- public class JSFUtils {
- private static final String NO_RESOURCE_FOUND = "Missing resource: ";
- /**
- * Method for taking a reference to a JSF binding expression and returning
- * the matching object (or creating it).
- * @param expression EL expression
- * @return Managed object
- */
- public static Object resolveExpression(String expression) {
- FacesContext facesContext = getFacesContext();
- Application app = facesContext.getApplication();
- ExpressionFactory elFactory = app.getExpressionFactory();
- ELContext elContext = facesContext.getELContext();
- ValueExpression valueExp =
- elFactory.createValueExpression(elContext, expression,
- Object.class);
- return valueExp.getValue(elContext);
- }
- /**
- * @return
- */
- public static String resolveRemoteUser() {
- FacesContext facesContext = getFacesContext();
- ExternalContext ectx = facesContext.getExternalContext();
- return ectx.getRemoteUser();
- }
- /**
- * @return
- */
- public static String resolveUserPrincipal() {
- FacesContext facesContext = getFacesContext();
- ExternalContext ectx = facesContext.getExternalContext();
- HttpServletRequest request = (HttpServletRequest)ectx.getRequest();
- return request.getUserPrincipal().getName();
- }
- /**
- * @param expression
- * @param returnType
- * @param argTypes
- * @param argValues
- * @return
- */
- public static Object resolveMethodExpression(String expression,
- Class returnType,
- Class[] argTypes,
- Object[] argValues) {
- FacesContext facesContext = getFacesContext();
- Application app = facesContext.getApplication();
- ExpressionFactory elFactory = app.getExpressionFactory();
- ELContext elContext = facesContext.getELContext();
- MethodExpression methodExpression =
- elFactory.createMethodExpression(elContext, expression, returnType,
- argTypes);
- return methodExpression.invoke(elContext, argValues);
- }
- /**
- * Method for taking a reference to a JSF binding expression and returning
- * the matching Boolean.
- * @param expression EL expression
- * @return Managed object
- */
- public static Boolean resolveExpressionAsBoolean(String expression) {
- return (Boolean)resolveExpression(expression);
- }
- /**
- * Method for taking a reference to a JSF binding expression and returning
- * the matching String (or creating it).
- * @param expression EL expression
- * @return Managed object
- */
- public static String resolveExpressionAsString(String expression) {
- return (String)resolveExpression(expression);
- }
- /**
- * Convenience method for resolving a reference to a managed bean by name
- * rather than by expression.
- * @param beanName name of managed bean
- * @return Managed object
- */
- public static Object getManagedBeanValue(String beanName) {
- StringBuffer buff = new StringBuffer("#{");
- buff.append(beanName);
- buff.append("}");
- return resolveExpression(buff.toString());
- }
- /**
- * Method for setting a new object into a JSF managed bean
- * Note: will fail silently if the supplied object does
- * not match the type of the managed bean.
- * @param expression EL expression
- * @param newValue new value to set
- */
- public static void setExpressionValue(String expression, Object newValue) {
- FacesContext facesContext = getFacesContext();
- Application app = facesContext.getApplication();
- ExpressionFactory elFactory = app.getExpressionFactory();
- ELContext elContext = facesContext.getELContext();
- ValueExpression valueExp =
- elFactory.createValueExpression(elContext, expression,
- Object.class);
- //Check that the input newValue can be cast to the property type
- //expected by the managed bean.
- //If the managed Bean expects a primitive we rely on Auto-Unboxing
- Class bindClass = valueExp.getType(elContext);
- if (bindClass.isPrimitive() || bindClass.isInstance(newValue)) {
- valueExp.setValue(elContext, newValue);
- }
- }
- /**
- * Convenience method for setting the value of a managed bean by name
- * rather than by expression.
- * @param beanName name of managed bean
- * @param newValue new value to set
- */
- public static void setManagedBeanValue(String beanName, Object newValue) {
- StringBuffer buff = new StringBuffer("#{");
- buff.append(beanName);
- buff.append("}");
- setExpressionValue(buff.toString(), newValue);
- }
- /**
- * Convenience method for setting Session variables.
- * @param key object key
- * @param object value to store
- */
- public static
- void storeOnSession(String key, Object object) {
- FacesContext ctx = getFacesContext();
- Map sessionState = ctx.getExternalContext().getSessionMap();
- sessionState.put(key, object);
- }
- /**
- * Convenience method for getting Session variables.
- * @param key object key
- * @return session object for key
- */
- public static Object getFromSession(String key) {
- FacesContext ctx = getFacesContext();
- Map sessionState = ctx.getExternalContext().getSessionMap();
- return sessionState.get(key);
- }
- /**
- * @param key
- * @return
- */
- public static String getFromHeader(String key) {
- FacesContext ctx = getFacesContext();
- ExternalContext ectx = ctx.getExternalContext();
- return ectx.getRequestHeaderMap().get(key);
- }
- /**
- * Convenience method for getting Request variables.
- * @param key object key
- * @return session object for key
- */
- public static Object getFromRequest(String key) {
- FacesContext ctx = getFacesContext();
- Map sessionState = ctx.getExternalContext().getRequestMap();
- return sessionState.get(key);
- }
- /**
- * Pulls a String resource from the property bundle that
- * is defined under the application <message-bundle> element in
- * the faces config. Respects Locale
- * @param key string message key
- * @return Resource value or placeholder error String
- */
- public static String getStringFromBundle(String key) {
- ResourceBundle bundle = getBundle();
- return getStringSafely(bundle, key, null);
- }
- /**
- * Convenience method to construct a <code>FacesMesssage</code>
- * from a defined error key and severity
- * This assumes that the error keys follow the convention of
- * using <b>_detail</b> for the detailed part of the
- * message, otherwise the main message is returned for the
- * detail as well.
- * @param key for the error message in the resource bundle
- * @param severity severity of message
- * @return Faces Message object
- */
- public static FacesMessage getMessageFromBundle(String key,
- FacesMessage.Severity severity) {
- ResourceBundle bundle = getBundle();
- String summary = getStringSafely(bundle, key, null);
- String detail = getStringSafely(bundle, key + "_detail", summary);
- FacesMessage message = new FacesMessage(summary, detail);
- message.setSeverity(severity);
- return message;
- }
- /**
- * Add JSF info message.
- * @param msg info message string
- */
- public static void addFacesInformationMessage(String msg) {
- FacesContext ctx = getFacesContext();
- FacesMessage fm =
- new FacesMessage(FacesMessage.SEVERITY_INFO, msg, "");
- ctx.addMessage(getRootViewComponentId(), fm);
- }
- /**
- * Add JSF error message.
- * @param msg error message string
- */
- public static void addFacesErrorMessage(String msg) {
- FacesContext ctx = getFacesContext();
- FacesMessage fm =
- new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, "");
- ctx.addMessage(getRootViewComponentId(), fm);
- }
- /**
- * Add JSF error message for a specific attribute.
- * @param attrName name of attribute
- * @param msg error message string
- */
- public static void addFacesErrorMessage(String attrName, String msg) {
- FacesContext ctx = getFacesContext();
- FacesMessage fm =
- new FacesMessage(FacesMessage.SEVERITY_ERROR, attrName, msg);
- ctx.addMessage(getRootViewComponentId(), fm);
- }
- // Informational getters
- /**
- * Get view id of the view root.
- * @return view id of the view root
- */
- public static String getRootViewId() {
- return getFacesContext().getViewRoot().getViewId();
- }
- /**
- * Get component id of the view root.
- * @return component id of the view root
- */
- public static String getRootViewComponentId() {
- return getFacesContext().getViewRoot().getId();
- }
- /**
- * Get FacesContext.
- * @return FacesContext
- */
- public static FacesContext getFacesContext() {
- return FacesContext.getCurrentInstance();
- }
- /*
- * Internal method to pull out the correct local
- * message bundle
- */
- private static ResourceBundle getBundle() {
- FacesContext ctx = getFacesContext();
- UIViewRoot uiRoot = ctx.getViewRoot();
- Locale locale = uiRoot.getLocale();
- ClassLoader ldr = Thread.currentThread().getContextClassLoader();
- return ResourceBundle.getBundle(ctx.getApplication().getMessageBundle(),
- locale, ldr);
- }
- /**
- * Get an HTTP Request attribute.
- * @param name attribute name
- * @return attribute value
- */
- public static Object getRequestAttribute(String name) {
- return getFacesContext().getExternalContext().getRequestMap().get(name);
- }
- /**
- * Set an HTTP Request attribute.
- * @param name attribute name
- * @param value attribute value
- */
- public static void setRequestAttribute(String name, Object value) {
- getFacesContext().getExternalContext().getRequestMap().put(name,
- value);
- }
- /*
- * Internal method to proxy for resource keys that don't exist
- */
- private static String getStringSafely(ResourceBundle bundle, String key,
- String defaultValue) {
- String resource = null;
- try {
- resource = bundle.getString(key);
- } catch (MissingResourceException mrex) {
- if (defaultValue != null) {
- resource = defaultValue;
- } else {
- resource = NO_RESOURCE_FOUND + key;
- }
- }
- return resource;
- }
- /**
- * Locate an UIComponent in view root with its component id. Use a recursive way to achieve this.
- * @param id UIComponent id
- * @return UIComponent object
- */
- public static UIComponent findComponentInRoot(String id) {
- UIComponent component = null;
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext != null) {
- UIComponent root = facesContext.getViewRoot();
- component = findComponent(root, id);
- }
- return component;
- }
- /**
- * Locate an UIComponent from its root component.
- * Taken from http://www.jroller.com/page/mert?entry=how_to_find_a_uicomponent
- * @param base root Component (parent)
- * @param id UIComponent id
- * @return UIComponent object
- */
- public static UIComponent findComponent(UIComponent base, String id) {
- if (id.equals(base.getId()))
- return base;
- UIComponent children = null;
- UIComponent result = null;
- Iterator childrens = base.getFacetsAndChildren();
- while (childrens.hasNext() && (result == null)) {
- children = (UIComponent)childrens.next();
- if (id.equals(children.getId())) {
- result = children;
- break;
- }
- result = findComponent(children, id);
- if (result != null) {
- break;
- }
- }
- return result;
- }
- /**
- * Method to create a redirect URL. The assumption is that the JSF servlet mapping is
- * "faces", which is the default
- *
- * @param view the JSP or JSPX page to redirect to
- * @return a URL to redirect to
- */
- public static String getPageURL(String view) {
- FacesContext facesContext = getFacesContext();
- ExternalContext externalContext = facesContext.getExternalContext();
- String url =
- ((HttpServletRequest)externalContext.getRequest()).getRequestURL().toString();
- StringBuffer newUrlBuffer = new StringBuffer();
- newUrlBuffer.append(url.substring(0, url.lastIndexOf("faces/")));
- newUrlBuffer.append("faces");
- String targetPageUrl = view.startsWith("/") ? view : "/" + view;
- newUrlBuffer.append(targetPageUrl);
- return newUrlBuffer.toString();
- }
- public static boolean isPostBack(){
- return JSFUtils.resolveExpressionAsBoolean("#{adfFacesContext.postback}");
- }
- }
JSFUtils
8>在jsf页面绑定的Managed Bean中引用am
在bean中获取am,在对应的jsf页面中必须有注册,否则返回空
ADFUtils.getApplicationModuleForDataControl("AppModuleAMDataControl");
9>jsf页面跳转,十一adf的link标签,设置destination属性
<af:link text="link 1" destination="" id="l1"/>
程序员的基础教程:菜鸟程序员
adf笔记的更多相关文章
- adf 笔记
1>jsf在bean中如何获取url参数,注意bean的范围,如果存在分页,范围不能设置为request,否则第二次加载的时候参数会为空. 最小设置为view,在当前页面中一直有效. 方法一:F ...
- Android学习笔记(二)——探究一个活动
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 活动(Activity)是最容易吸引到用户的地方了,它是一种可以包含用户界面的组件,主要用于和用户进行交互.一 ...
- ArcGIS API for Silverlight学习笔记
ArcGIS API for Silverlight学习笔记(一):为什么要用Silverlight API(转) 你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我都 ...
- 23 DesignPatterns学习笔记:C++语言实现 --- 1.1 Factory
23 DesignPatterns学习笔记:C++语言实现 --- 1.1 Factory 2016-07-18 13:03:43 模式理解
- 《时间序列分析——基于R》王燕,读书笔记
笔记: 一.检验: 1.平稳性检验: 图检验方法: 时序图检验:该序列有明显的趋势性或周期性,则不是平稳序列 自相关图检验:(acf函数)平稳序列具有短期相关性,即随着延迟期数k的增加 ...
- git-简单流程(学习笔记)
这是阅读廖雪峰的官方网站的笔记,用于自己以后回看 1.进入项目文件夹 初始化一个Git仓库,使用git init命令. 添加文件到Git仓库,分两步: 第一步,使用命令git add <file ...
- js学习笔记:webpack基础入门(一)
之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...
- SQL Server技术内幕笔记合集
SQL Server技术内幕笔记合集 发这一篇文章主要是方便大家找到我的笔记入口,方便大家o(∩_∩)o Microsoft SQL Server 6.5 技术内幕 笔记http://www.cnbl ...
- PHP-自定义模板-学习笔记
1. 开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2. 整体架构图 ...
随机推荐
- 1.Python3关于文件的操作
1.写了一个简单的Demo,就是向txt文本写入内容,最初代码如下: file = open("D:/Users/nancy/python.txt","wb") ...
- 使用Octave分析GNU Radio的数据
Octave 是 GNU Radio 的最流行的分析工具,因此 GNU Radio 软件包也包含它自身的一组脚本用于读取和语法分析输出.本文介绍如何使用 Octave 分析 GNU Radio 产生的 ...
- JVM内存管理之GC算法精解(复制算法与标记/整理算法)
本次LZ和各位分享GC最后两种算法,复制算法以及标记/整理算法.上一章在讲解标记/清除算法时已经提到过,这两种算法都是在此基础上演化而来的,究竟这两种算法优化了之前标记/清除算法的哪些问题呢? 复制算 ...
- 如何安装nginx第三方模块
nginx文件非常小但是性能非常的高效,这方面完胜apache,nginx文件小的一个原因之一是nginx自带的功能相对较少,好在nginx允许第三方模块,第三方模块使得nginx越发的强大. 在安装 ...
- 关于INTEL FPGA设计工具DSP Builder
一段时间以来,MathWorks一直主张使用Matlab和Simulink开发工具进行基于模型的设计,因为好的设计技术使您能够在更短的时间内开发更高质量的复杂软件.基于模块的设计采用了数学和可视化的方 ...
- NAT功能测试
一.测试目标和功能: 1.内网设备可以访问外网的IP: 2.外网PC可以登录内网设备的telnet. 二.设备硬件结构 1.3135相当于交换机: 2.eth0.netra和业务网口通过内部端口连接3 ...
- Android多线程断点下载的代码流程解析
Step 1:创建一个用来记录线程下载信息的表 创建数据库表,于是乎我们创建一个数据库的管理器类,继承SQLiteOpenHelper类 重写onCreate()与onUpgrade()方法 DBOp ...
- Oracle查询结果中的日期格式显示到毫秒数,如何去掉多余的数
@Temporal(TemporalType.TIMESTAMP) @Column(name="createTime",nullable=false) private Date c ...
- Angular2快速入门-5.使用http(新闻数据来自http请求)
Angular2官网通过http请求模拟API 来请求hero 数据,感觉有点繁琐,很让人理解不了,我们不采用它的办法,直接展示怎么使用http请求来获取我们的数据 ,直截了当. 第一.准备工作,创建 ...
- 函数~匿名方法~lambda的逐渐过渡思想
前提:基于委托实现 (1)使用函数名称 delegate void Printer(string s);//(1)申明委托 static void Main(string[] args) { //(3 ...