当前位置: 首页>>代码示例>>Java>>正文


Java FacesException类代码示例

本文整理汇总了Java中javax.faces.FacesException的典型用法代码示例。如果您正苦于以下问题:Java FacesException类的具体用法?Java FacesException怎么用?Java FacesException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FacesException类属于javax.faces包,在下文中一共展示了FacesException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderView

import javax.faces.FacesException; //导入依赖的package包/类
public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException {
	// SAK-20286 start
	// Get the request
	HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
	String requestURI = req.getRequestURI();
	// Make the attribute name unique to the request 
	String attrName = "sakai.jsf.tool.URL.loopDetect.viewId-" + requestURI;
	// Try to fetch the attribute
	Object attribute = req.getAttribute(attrName);
	// If the attribute is null, this is the first request for this view
	if (attribute == null) {
		req.setAttribute(attrName, "true");
	} else if ("true".equals(attribute)) { // A looping request is detected.
		HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse();
		// Send a 404
		res.sendError(404, "File not found: " + requestURI);
	}
	// SAK-20286 end
	m_wrapped.renderView(context, root);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:21,代码来源:SakaiViewHandler.java

示例2: resolve

import javax.faces.FacesException; //导入依赖的package包/类
public List<UIComponent> resolve(UIComponent component, List<UIComponent> parentComponents, String currentId,
		String originalExpression, String[] parameters) {

	List<UIComponent> result = new ArrayList<UIComponent>();
	for (UIComponent parent : parentComponents) {
		UIComponent searchRoot = parent;
		while ((!(searchRoot instanceof UIViewRoot)) && (!(searchRoot instanceof NamingContainer))) {
			searchRoot = searchRoot.getParent();
		}
			
		List<UIComponent> c = findIdsRecursively(searchRoot, parameters[0]);
		if (null != c) {
			result.addAll(c);
		}
	}
	if (result.size() > 0) {
		return result;
	}

	throw new FacesException("Invalid search expression - couldn't find id " + currentId + ". Complete search expression: " + originalExpression);
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:22,代码来源:FindIdRecursiveExpressionResolver.java

示例3: aclCheck

import javax.faces.FacesException; //导入依赖的package包/类
public boolean aclCheck(String fragment, Object contextData) {
	boolean isAccessAllowed;
	try {
		Object[] runtime = new Object[1];
		if (contextData != null) {
			runtime[0] = contextData;
		}

		UIContext securityContext = new UIContext(getUser(userModule));
		securityContext.setFragment(fragment);
		securityContext.setContextData(runtime);
		isAccessAllowed = forumsACLProvider.hasAccess(securityContext);
	} catch (NoSuchMethodException nsme) {
		throw new FacesException(nsme);
	} catch (Exception e) {
		throw new FacesException(e);
	}

	return isAccessAllowed;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:21,代码来源:ACLRenderingController.java

示例4: accessAllowed

import javax.faces.FacesException; //导入依赖的package包/类
@AroundInvoke
public Object accessAllowed(InvocationContext ctx) throws Exception {
	Method businessAction = ctx.getMethod();
	Object managedBean = ctx.getTarget();
	boolean isAccessAllowed = false;

	try {

		ActionContext securityContext = new ActionContext(getUser(userModule));
		securityContext.setBusinessAction(businessAction);
		securityContext.setManagedBean(managedBean);

		isAccessAllowed = forumsACLProvider.hasAccess(securityContext);
		if (!isAccessAllowed)
			return null;
	} catch (NoSuchMethodException nsme) {
		throw new FacesException("Error calling action method of component with id " + nsme, nsme);
	} catch (Exception e) {
		throw new FacesException("Error calling action method of component with id " + e, e);
	}
	return ctx.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:23,代码来源:AuthorizationListener.java

示例5: execute

import javax.faces.FacesException; //导入依赖的package包/类
/**
 * Convert a EJBException into FacesMessage which is presented to the user.
 * 
 * @param ex
 *            the EJBException to be analyzed
 */
public static void execute(EJBException ex) {
    if (ex != null && ex.getCause() instanceof Exception
            && ex.getCausedByException() instanceof AccessException) {
        handleOrganizationAuthoritiesException();
    } else if (ex != null && isInvalidUserSession(ex)) {
        HttpServletRequest request = JSFUtils.getRequest();
        request.getSession().removeAttribute(Constants.SESS_ATTR_USER);
        request.getSession().invalidate();
        handleInvalidSession();
    } else if (ex != null && isConnectionException(ex)) {
        handleMissingConnect(BaseBean.ERROR_DATABASE_NOT_AVAILABLE);
    } else {
        throw new FacesException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:ExceptionHandler.java

示例6: apply

import javax.faces.FacesException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void apply(FaceletContext faceletContext,
        UIComponent parent) throws IOException, FacesException, FaceletException, ELException
{
  if(ComponentHandler.isNew(parent))
  {
    ActionSource actionSource = (ActionSource)parent;
    ReturnActionListener listener = new ReturnActionListener();
    if (_value != null)
    {
      ValueExpression valueExp = _value.getValueExpression(faceletContext, Object.class);
      listener.setValueExpression(ReturnActionListener.VALUE_KEY,valueExp);
    }

    actionSource.addActionListener(listener);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:ReturnActionListenerTag.java

示例7: renderView

import javax.faces.FacesException; //导入依赖的package包/类
@Override
public void renderView(
  FacesContext context,
  UIViewRoot   viewToRender) throws IOException, FacesException
{
  String entryKey = (String) context.getExternalContext().getRequestParameterMap().get(__ENTRY_KEY_PARAM);
  if (entryKey == null)
  {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    if (requestContext != null)
    {
      Object o = requestContext.getPageFlowScope().get(__ENTRY_KEY_PARAM);
      if (o != null)
        entryKey = o.toString();
    }
  }

  service(context,entryKey);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:GenericEntry.java

示例8: visit

import javax.faces.FacesException; //导入依赖的package包/类
public VisitResult visit(
  VisitContext context,
  UIComponent  target)
{
  try
  {
    // we have the subtree we want, render it
    target.encodeAll(context.getFacesContext());
  }
  catch (IOException ioe)
  {
    // launder the IOException as a FacesException, we'll unwrap this later
    throw new FacesException(ioe);
  }

  PartialPageContext pprContext = RenderingContext.getCurrentInstance().getPartialPageContext();

  // if we finished rendering all of the destired targets, return that we are
  // done.  Otherwise, reject this subtree so that we don't traverse into it, since
  // we have already rendered all of the targets in it
  if (pprContext.areAllTargetsProcessed())
    return VisitResult.COMPLETE;
  else
    return VisitResult.REJECT;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:PanelPartialRootRenderer.java

示例9: renderView

import javax.faces.FacesException; //导入依赖的package包/类
@Override
public void renderView(FacesContext context, UIViewRoot viewToRender)
  throws IOException, FacesException
{
  if (!isEnabled())
  {
    _sendPregenerationDisabledError(context);
    return;
  }
  
  long duration = _pregenerateSkin(context);    
  
  if (!context.getResponseComplete())
  {
    _renderResponse(context, duration);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:SkinPregenerationService.java

示例10: getContextClassLoader

import javax.faces.FacesException; //导入依赖的package包/类
/**
 * Dynamically accesses the current context class loader. 
 * Includes a check for priviledges against java2 security 
 * to ensure no security related exceptions are encountered. 
 * Returns null if there is no per-thread context class loader.
 */
public static ClassLoader getContextClassLoader()
{
    if (System.getSecurityManager() != null) 
    {
        try 
        {
            ClassLoader cl = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
                    {
                        public ClassLoader run() throws PrivilegedActionException
                        {
                            return Thread.currentThread().getContextClassLoader();
                        }
                    });
            return cl;
        }
        catch (PrivilegedActionException pae)
        {
            throw new FacesException(pae);
        }
    }
    else
    {
        return Thread.currentThread().getContextClassLoader();
    }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:32,代码来源:ClassLoaderUtils.java

示例11: getResources

import javax.faces.FacesException; //导入依赖的package包/类
/**
 * @param resource       Name of resource(s) to find in classpath
 * @param defaultObject  The default object to use to determine the class loader 
 *                       (if none associated with current thread.)
 * @return Iterator over URL Objects
 */
public static Iterator getResources(String resource, Object defaultObject)
{
    try
    {
        Enumeration resources = getCurrentLoader(defaultObject).getResources(resource);
        List lst = new ArrayList();
        while (resources.hasMoreElements())
        {
            lst.add(resources.nextElement());
        }
        return lst.iterator();
    }
    catch (IOException e)
    {
        log.log(Level.SEVERE, e.getMessage(), e);
        throw new FacesException(e);
    }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:ClassUtils.java

示例12: newInstance

import javax.faces.FacesException; //导入依赖的package包/类
public static Object newInstance(String type, Class[] expectedTypes)
{
    if (type == null)
    {
        return null;
    }
    
    Class clazzForName = simpleClassForName(type);
    
    if(expectedTypes != null)
    {
        for (int i = 0, size = expectedTypes.length; i < size; i++)
        {
            if (!expectedTypes[i].isAssignableFrom(clazzForName))
            {
                throw new FacesException("'" + type + "' does not implement expected type '" + expectedTypes[i]
                        + "'");
            }
        }
    }
    
    return newInstance(clazzForName);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:24,代码来源:ClassUtils.java

示例13: convertToType

import javax.faces.FacesException; //导入依赖的package包/类
public static Object convertToType(Object value, Class desiredClass)
{
    if (value == null)
    {
        return null;
    }

    try
    {
        ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
        return expFactory.coerceToType(value, desiredClass);
    }
    catch (Exception e)
    {
        String message = "Cannot coerce " + value.getClass().getName()
                         + " to " + desiredClass.getName();
        log.log(Level.SEVERE, message, e);
        throw new FacesException(message, e);
    }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:ClassUtils.java

示例14: construct

import javax.faces.FacesException; //导入依赖的package包/类
/**
 * This fires during the Render Response phase, saving state.
 */

public static final String construct(Object object, ExternalContext ctx)
{
    byte[] bytes = getAsByteArray(object, ctx);
    if( enableCompression(ctx) )
    {
        bytes = compress(bytes);
    }
    if(isSecure(ctx))
    {
        bytes = encrypt(bytes, ctx);
    }
    bytes = encode(bytes);
    try
    {
        return new String(bytes, ZIP_CHARSET);
    }
    catch (UnsupportedEncodingException e)
    {
        throw new FacesException(e);
    }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:StateUtils.java

示例15: compress

import javax.faces.FacesException; //导入依赖的package包/类
public static final byte[] compress(byte[] bytes)
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try
    {
        GZIPOutputStream gzip = new GZIPOutputStream(baos);
        gzip.write(bytes, 0, bytes.length);
        gzip.finish();
        byte[] fewerBytes = baos.toByteArray();
        gzip.close();
        baos.close();
        gzip = null;
        baos = null;
        return fewerBytes;
    }
    catch (IOException e)
    {
        throw new FacesException(e);
    }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:StateUtils.java


注:本文中的javax.faces.FacesException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。