本文整理汇总了Java中javax.faces.view.facelets.FaceletContext类的典型用法代码示例。如果您正苦于以下问题:Java FaceletContext类的具体用法?Java FaceletContext怎么用?Java FaceletContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FaceletContext类属于javax.faces.view.facelets包,在下文中一共展示了FaceletContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyMetadata
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public void applyMetadata(FaceletContext ctx, Object instance)
{
Class klass = instance.getClass();
try
{
Method setter = klass.getMethod("setValueExpression", _SETTER_ARGS);
setter.invoke(instance, new Object[]{_name, _attr.getValueExpression(ctx, _type)});
}
// No user-readable messages are needed since we should never install this rule
// for objects not supportingg setvalueExpression()
catch (NoSuchMethodException ncm)
{
_LOG.severe(ncm);
}
catch(IllegalAccessException iae)
{
_LOG.severe(iae);
}
catch(InvocationTargetException ite)
{
_LOG.severe(ite);
}
}
示例2: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public void apply(FaceletContext faceletContext,
UIComponent parent) throws FaceletException, ELException
{
if (ComponentHandler.isNew(parent))
{
// =-=AEW Couldn't this be cached?
ValueExpression fromExpression = _from.getValueExpression(faceletContext,
Object.class);
ValueExpression toExpression= _to.getValueExpression(faceletContext,
Object.class);
ActionSource actionSource= (ActionSource) parent;
SetActionListener listener = new SetActionListener();
listener.setValueExpression("from", fromExpression);
listener.setValueExpression("to", toExpression);
actionSource.addActionListener(listener);
}
}
示例3: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的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);
}
}
示例4: applyMetadata
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public void applyMetadata(FaceletContext ctx, Object instance)
{
ValueExpression expr = _attribute.getValueExpression(ctx, String.class);
UIXComponent uixcomp = (UIXComponent) instance;
FacesBean bean = uixcomp.getFacesBean();
PropertyKey mainKey = bean.getType().findKey(_mainMethodName);
if (mainKey == null)
throw new TagAttributeException(_attribute,
"No support for '" + _mainMethodName +
"' attribute on " + instance);
PropertyKey accessKeyKey = bean.getType().findKey("accessKey");
if (accessKeyKey == null)
throw new TagAttributeException(_attribute,
"No support for 'accessKey' attribute on " + instance);
VirtualAttributeUtils.setAccessKeyAttribute(bean, expr, mainKey, accessKeyKey);
}
示例5: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Override
public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException {
if (SecurityContextHolder.getContext().getAuthentication() == null) {
return;
}
AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag(faceletContext, this.access, this.url, this.method, this.ifAllGranted, this.ifAnyGranted, this.ifNotGranted);
boolean isAuthorized = authorizeTag.authorize();
if (isAuthorized) {
this.nextHandler.apply(faceletContext, parent);
}
if (this.var != null) {
faceletContext.setAttribute(this.var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
}
}
示例6: testApplyVar
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Test
public void testApplyVar() throws IOException {
Authentication authentication = AuthenticationFactory.authentication(Roles.ROLE_A);
new SpringSecurityMock().init(authentication);
MockTagAttribute myVariableTagAttribute = new MockTagAttribute("myVariable");
getJsfMock().getMockTagAttributes().getTagAttributes().put(
"var", myVariableTagAttribute);
getJsfMock().getMockTagAttributes().getTagAttributes().put(
"ifAllGranted", new MockTagAttribute(Roles.ROLE_A));
FaceletContext mockFaceletContext = getJsfMock().getMockFaceletContext();
AuthorizeFaceletsTagHandler tag = new AuthorizeFaceletsTagHandler(
getJsfMock().getMockTagConfig());
tag.apply(mockFaceletContext, null);
assertThat(mockFaceletContext.getAttribute("myVariable"))
.isEqualTo(Boolean.TRUE);
}
示例7: setAttributes
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Override
public void setAttributes(FaceletContext ctx, Object instance)
{
EntityConverter converter = (EntityConverter) instance;
if (this.nullEntity != null) {
converter.setNullEntity(this.nullEntity.getValue(ctx));
}
if (this.transientEntity != null) {
converter.setTransientEntity(this.transientEntity.getValue(ctx));
}
if (this.entityManager != null) {
converter.setEntityManager((EntityManager) this.entityManager.getObject(ctx));
}
if (this.targetEntityClass != null) {
converter.setTargetEntityClass(this.targetEntityClass.getValue(ctx));
}
}
示例8: setAttr
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public void setAttr(FaceletContext ctx, String name, TagAttribute attr, UIComponent target) {
String value = attr.getValue(ctx);
target.getAttributes().put(name, value);
// value = new Object[] { ctx.getExpressionFactory().coerceToType(str, method.getParameterTypes()[0]) };
//
// try {
// method.invoke(instance, this.value);
// } catch (InvocationTargetException e) {
// throw new TagAttributeException(this.attribute, e.getCause());
// } catch (Exception e) {
// throw new TagAttributeException(this.attribute, e);
// }
// if (targetExpr != null) {
// ValueExpression srcExpr = attr.getValueExpression(ctx, targetExpr.getType(elContext));
// targetExpr.setValue(elContext, value);
// } else {
// ExpressionFactory exprFactory = ctx.getFacesContext().getApplication().getExpressionFactory();
// targetExpr = exprFactory.createValueExpression(elContext, "#{" + name + "}", value.getClass());
// target.setValueExpression(name, targetExpr);
// targetExpr.setValue(elContext, value);
// }
}
示例9: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException
{
VariableMapper overloadedVarMapper = ctx.getVariableMapper();
try
{
CompositeVariableMapper compositeVarMapper = new CompositeVariableMapper(overloadedVarMapper);
ctx.setVariableMapper(compositeVarMapper);
this.nextHandler.apply(ctx, parent);
}
finally
{
ctx.setVariableMapper(overloadedVarMapper);
}
}
示例10: aclCheck
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public boolean aclCheck(String fragment, String contextData, ForumsACLProvider forumsACLProvider,
UserModule userModule, FaceletContext ctx) {
boolean isAccessAllowed;
try {
Object[] runtime = null;
FacesContext facesContext = ctx.getFacesContext();
if (contextData != null && contextData.trim().length() > 0) {
StringTokenizer st = new StringTokenizer(contextData, ",");
runtime = new Object[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
String parameter = st.nextToken();
Object parameterValue = null;
ExpressionFactory f = ctx.getExpressionFactory();
ValueExpression expr = f.createValueExpression(ctx, parameter, Object.class);
parameterValue = expr.getValue(facesContext.getELContext());
runtime[i++] = parameterValue;
}
}
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,代码行数:35,代码来源:ACLRenderingController.java
示例11: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException {
if (when.isAllowed(ctx)) {
when.apply(ctx, parent);
return;
} else {
if (otherwise != null) {
otherwise.apply(ctx, parent);
}
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:11,代码来源:ACLChooseTagHandler.java
示例12: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@TransactionAttribute
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException {
ForumsACLProvider forumsACLProvider = (ForumsACLProvider) forumsACLProviderAttr.getObject(ctx);
UserModule userModule = (UserModule) userModuleAttr.getObject(ctx);
boolean skipAuth = false;
try {
if (forumsACLProvider == null) {
skipAuth = true;
}
} catch (Exception e) {
skipAuth = true;
}
if (skipAuth) {
nextHandler.apply(ctx, parent);
return;
}
String resource = fragment.getValue();
String contextStr = null;
if (this.contextData != null) {
contextStr = contextData.getValue();
}
boolean isAccessAllowed = new ACLRenderingController().aclCheck(resource, contextStr, forumsACLProvider,
userModule, ctx);
if (isAccessAllowed) {
nextHandler.apply(ctx, parent);
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:32,代码来源:ACLTagHandler.java
示例13: apply
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
public void apply(FaceletContext faceletContext,
UIComponent parent) throws IOException, FacesException, FaceletException, ELException
{
if(ComponentHandler.isNew(parent))
{
ActionSource actionSource = (ActionSource)parent;
ResetActionListener listener = new ResetActionListener();
actionSource.addActionListener(listener);
}
}
示例14: onComponentPopulated
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
@Override
public void onComponentPopulated(FaceletContext context,
UIComponent component,
UIComponent parent)
{
assert (_markInitialState != null);
if ((component instanceof UIXComponent) &&
(_markInitialState == Boolean.TRUE))
{
if (component.getId() == null)
component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
PhaseId phase = context.getFacesContext().getCurrentPhaseId();
// In jsf2 markInitialState will be called by the framework during restore view,
// and in fact the framework should always be the one
// calling markInitialState, but it doesn't always do that in render response, see
// http://java.net/jira/browse/JAVASERVERFACES-2285
// Also don't call markInitialState unless initialStateMarked returns false, otherwise
// any deltas previously saved may get blown away.
if (PhaseId.RENDER_RESPONSE.equals(phase) && !component.initialStateMarked())
{
component.markInitialState();
}
}
}
示例15: setAttributes
import javax.faces.view.facelets.FaceletContext; //导入依赖的package包/类
/**
* Invoking/extending this method will cause the results of the created
* MetaRuleset to auto-wire state to the passed instance.
*
* @param ctx
* @param instance
*/
protected void setAttributes(FaceletContext ctx, Object instance) {
if (instance != null) {
Class type = instance.getClass();
if (mapper == null || !this.lastType.equals(type)) {
this.lastType = type;
this.mapper = this.createMetaRuleset(type).finish();
}
this.mapper.applyMetadata(ctx, instance);
}
}