• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientBehavior类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: hasAjaxBahavior

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
private boolean hasAjaxBahavior(UIComponent component)
{
  if (!(component instanceof ClientBehaviorHolder))
  {
    return false;
  }
  ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
  for (List<ClientBehavior> behaviors : holder.getClientBehaviors().values())
  {
    for (ClientBehavior behavior : behaviors)
    {
      if (behavior instanceof AjaxBehavior)
      {
        return true;
      }
    }
  }
  
  return false;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:XhtmlRenderer.java


示例2: findClientIdsToDisableOnRequest

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
private Set<String> findClientIdsToDisableOnRequest(final ClientBehaviorHolder clientBehaviorHolder) {
    final Set<String> renderClientIds = new HashSet<>();
    if (!clientBehaviorHolder.getClientBehaviors().isEmpty()) {
        final Collection<List<ClientBehavior>> clientBehaviors = clientBehaviorHolder.getClientBehaviors().values();

        for (List<ClientBehavior> clientBehavior : clientBehaviors) {
            for (ClientBehavior behavior : clientBehavior) {
                if (behavior instanceof AjaxBehavior) {
                    final AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
                    for (String render : ajaxBehavior.getRender()) {
                        if (StringUtils.isNotEmpty(render)) {
                            renderClientIds.add(render.trim());
                        }
                    }
                }
            }
        }
    }
    return renderClientIds;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:21,代码来源:AjaxClientIdResolver.java


示例3: testRenderByComponentEvent

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
@Test
public void testRenderByComponentEvent() throws Exception {
    final Map<String, List<ClientBehavior>> behaviors = new HashMap<>();
    behaviors.put("click", Arrays.<ClientBehavior>asList(
            createAjaxBehavior(true, "disabled"),
            createAjaxBehavior(false, "@all"),
            createAjaxBehavior(false, "@none"),
            createAjaxBehavior(false, "@this"),
            createAjaxBehavior(false, "@form"),
            createAjaxBehavior(false, "enabled")));

    final UIComponentBase uiComponentMock = mock(UIComponentBase.class);
    when(uiComponentMock.getClientBehaviors()).thenReturn(behaviors);

    final JsfAjaxRequest requestBuilder = new JsfAjaxRequest("mySourceElement", false);

    assertThat(requestBuilder.setRender(uiComponentMock, "toggle").toString())
            .isEqualTo("jsf.ajax.request(mySourceElement);");
    assertThat(requestBuilder.setRender(uiComponentMock, "click").toString())
            .isEqualTo("jsf.ajax.request(mySourceElement, {render: '@all @none @this @form enabled'});");
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:22,代码来源:JsfAjaxRequestTest.java


示例4: decodeBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
private void decodeBehaviors(FacesContext context, UIComponent component) {
	if (!(component instanceof ClientBehaviorHolder))
		return;

	Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
	if (behaviors.isEmpty())
		return;

	Map<String, String> params = context.getExternalContext().getRequestParameterMap();
	String behaviorEvent = params.get("javax.faces.behavior.event");

	if (behaviorEvent != null) {
		List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);

		if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
			String behaviorSource = params.get("javax.faces.source");
			String clientId = component.getClientId();

			if (behaviorSource != null && clientId.equals(behaviorSource)) {
				for (ClientBehavior behavior : behaviorsForEvent)
					behavior.decode(context, component);
			}
		}
	}
}
 
开发者ID:edvin,项目名称:tornadofaces,代码行数:26,代码来源:CoreRenderer.java


示例5: decodeBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
protected void decodeBehaviors(FacesContext context, UIComponent component) {
	if (!(component instanceof ClientBehaviorHolder)) {
		return;
	}

	Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
	if (behaviors.isEmpty()) {
		return;
	}

	Map<String, String> params = context.getExternalContext().getRequestParameterMap();
	String behaviorEvent = params.get("javax.faces.behavior.event");
	if (null != behaviorEvent) {
		List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);

		if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
			String behaviorSource = params.get("javax.faces.source");
			String clientId = component.getClientId(context);
			if (behaviorSource != null && clientId.equals(behaviorSource)) {
				for (ClientBehavior behavior : behaviorsForEvent) {
					behavior.decode(context, component);
				}
			}
		}
	}
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:27,代码来源:CoreRenderer.java


示例6: getClientBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public Map<String, List<ClientBehavior>> getClientBehaviors()
{
  Map<String, List<ClientBehavior>> behaviors = _EMPTY_CLIENT_BEHAVIORS_MAP;
  if (_component instanceof ClientBehaviorHolder)
  {
    behaviors = ((ClientBehaviorHolder)_component).getClientBehaviors();
  }
  return behaviors;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:ComponentFacesBean.java


示例7: _hasSubmittingBehavior

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
private static boolean _hasSubmittingBehavior(
  Iterable<ClientBehavior> behaviors)
{
  for (ClientBehavior behavior : behaviors)
  {
    if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:13,代码来源:XhtmlUtils.java


示例8: getScript

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
@Override
public String getScript(
  ClientBehaviorContext clientBehaviorContext,
  ClientBehavior        clientBehavior)
{
  InvokeFunctionBehavior behavior = (InvokeFunctionBehavior)clientBehavior;
  String function = behavior.getFunction();
  return new StringBuilder(15 + function.length())
    .append("return ")
    .append(function)
    .append("(event);")
    .toString();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:14,代码来源:InvokeFunctionBehaviorRenderer.java


示例9: addClientBehavior

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
/**
 * Utility method to assist sub-classes in the implementation of the
 * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
 * <p>This method must only
 * be called by classes that implement the interface, doing otherwise will result in an exception.
 * </p>
 * @param eventName The event name
 * @param behavior The behavior to add
 * @see javax.faces.component.behavior.ClientBehaviorHolder#addClientBehavior(String, ClientBehavior)
 */
protected void addClientBehavior(
  String         eventName,
  ClientBehavior behavior)
{
  // This will throw a class cast exception when illegally called by a class that does not
  // implement ClientBehaviorHolder
  Collection<String> events = ((ClientBehaviorHolder)this).getEventNames();

  // This will throw a null pointer exception if the component author did not correctly implement
  // the ClientBehaviorHolder contract which requires a non-empty collection to be returned from
  // getEventNames
  if (!events.contains(eventName))
  {
    return;
  }

  FacesBean bean = getFacesBean();

  AttachedObjects<String, ClientBehavior> behaviors = (
          AttachedObjects<String, ClientBehavior>)bean.getProperty(_CLIENT_BEHAVIORS_KEY);

  if (behaviors == null)
  {
    behaviors = new AttachedObjects<String, ClientBehavior>();
    bean.setProperty(_CLIENT_BEHAVIORS_KEY, behaviors);
  }

  behaviors.addAttachedObject(eventName, behavior);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:40,代码来源:UIXComponentBase.java


示例10: getClientBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
/**
 * Utility method to assist sub-classes in the implementation of the
 * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
 * <p>This method must only
 * be called by classes that implement the interface, doing otherwise will result in an exception.
 * </p>
 * @see javax.faces.component.behavior.ClientBehaviorHolder#getClientBehaviors()
 * @return Read-only map of the client behaviors for this component
 */
protected Map<String, List<ClientBehavior>> getClientBehaviors()
{
  AttachedObjects<String, ClientBehavior> behaviors = (
          AttachedObjects<String, ClientBehavior>)getFacesBean().getProperty(_CLIENT_BEHAVIORS_KEY);

  if (behaviors == null)
  {
    return Collections.emptyMap();
  }

  return behaviors.getAttachedObjectMap();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:22,代码来源:UIXComponentBase.java


示例11: findFirstActiveAjaxBehavior

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public static AjaxBehavior findFirstActiveAjaxBehavior(final UIComponentBase component, final String eventName) {
    if (component != null) {
        final List<ClientBehavior> behaviors = component.getClientBehaviors().get(eventName);
        if (behaviors != null) {
            for (ClientBehavior behavior : behaviors) {
                if (behavior instanceof AjaxBehavior && !((AjaxBehavior) behavior).isDisabled()) {
                    return (AjaxBehavior) behavior;
                }
            }
        }
    }

    return null;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:15,代码来源:ClientBehaviorResolver.java


示例12: findAjaxBehavior

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
private static AjaxBehavior findAjaxBehavior(Map<String, List<ClientBehavior>> behaviors, String event) {
    if (behaviors.containsKey(event)) {
        final ClientBehavior clientBehavior = behaviors.get(event).get(0);

        if (clientBehavior instanceof AjaxBehavior && !((AjaxBehavior) clientBehavior).isDisabled()) {
            return ((AjaxBehavior) clientBehavior);
        }
    }

    return null;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:12,代码来源:ClientBehaviorResolver.java


示例13: decodeBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
protected final String decodeBehaviors(final FacesContext context,
                                       final UIComponent component) {
    if (!(component instanceof ClientBehaviorHolder)) {
        return null;
    }

    final ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
    final Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();

    if (behaviors.isEmpty()) {
        return null;
    }

    final ExternalContext external = context.getExternalContext();
    final Map<String, String> params = external.getRequestParameterMap();
    final String behaviorEvent = params.get("javax.faces.behavior.event");

    if (behaviorEvent != null) {
        final List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);

        if (behaviorsForEvent != null && behaviorsForEvent.size() > 0) {
            final String behaviorSource = params.get("javax.faces.source");
            final String clientId = component.getClientId();
            if (isBehaviorSource(behaviorSource, clientId)) {
                for (ClientBehavior behavior : behaviorsForEvent) {
                    behavior.decode(context, component);
                }
            }

            return clientId;
        }
    }

    return null;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:36,代码来源:HtmlBasicRenderer.java


示例14: decode

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
@Override
public void decode(FacesContext context, UIComponent component) {
    final HtmlTableToolbar tableToolbar = (HtmlTableToolbar) component;
    final Map<String, List<ClientBehavior>> behaviors = tableToolbar.getClientBehaviors();

    if (behaviors.isEmpty()) {
        return;
    }

    final ExternalContext external = context.getExternalContext();
    final Map<String, String> params = external.getRequestParameterMap();
    final String behaviorEvent = params.get("javax.faces.behavior.event");
    final HtmlTable table = getTableComponent(tableToolbar);
    final String tableUniqueIdentifier = table.getModelUniqueIdentifier();

    if (behaviorEvent != null) {
        if (HtmlTableToolbar.EVENT_TOGGLE_COLUMN.equals(behaviorEvent) && table.getTableColumnVisibilityModel() != null) {
            final TableColumnVisibility visibility = new JsonToModelConverter().convertTableColumnVisibility(tableUniqueIdentifier, params.get("params"));
            table.getTableColumnVisibilityModel().update(visibility);
        } else if (behaviorEvent.equals(HtmlTableToolbar.EVENT_REFRESH_TABLE)) {
            if (tableToolbar.getTableToolbarRefreshListener() != null) {
                tableToolbar.getTableToolbarRefreshListener().onPreRefresh();
            }
        } else if (HtmlTableToolbar.EVENT_ORDER_COLUMN.equals(behaviorEvent) && table.getTableOrderingModel() != null) {
            final TableColumnOrdering ordering = new JsonToModelConverter().convertTableColumnOrdering(tableUniqueIdentifier, params.get("params"));
            table.getTableOrderingModel().update(ordering);
        }
    }
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:30,代码来源:TableToolbarRenderer.java


示例15: createRerenderIds

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public static List<String> createRerenderIds(final UIComponentBase component, final String eventName) {
    final List<String> idsToRender = new ArrayList<>();
    final Map<String, List<ClientBehavior>> behaviors = component.getClientBehaviors();
    final List<ClientBehavior> refreshBehaviors = behaviors.get(eventName);

    if (refreshBehaviors == null) {
        return new ArrayList<>();
        //throw new IllegalArgumentException("Ajax event '" + eventName + "' not found on component '" + component.getClientId() + "'.");
    }

    boolean enabledAjaxEventFound = false;

    if (!refreshBehaviors.isEmpty()) {
        for (ClientBehavior refreshBehavior : refreshBehaviors) {
            if (refreshBehavior instanceof AjaxBehavior) {
                final AjaxBehavior ajaxBehavior = (AjaxBehavior) refreshBehavior;

                if (!ajaxBehavior.isDisabled()) {
                    if (ajaxBehavior.getRender() != null && !ajaxBehavior.getRender().isEmpty()) {
                        for (String singleRender : ajaxBehavior.getRender()) {
                            idsToRender.add(getResolvedId(component, singleRender));
                        }
                    }

                    enabledAjaxEventFound = true;
                }
            }
        }
    }

    if (!enabledAjaxEventFound) {
        return new ArrayList<>();
        //throw new IllegalStateException("Ajax event '" + eventName + "' on component '" + component.getClientId() + "' is disabled.");
    }

    return idsToRender;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:38,代码来源:JsfAjaxRequest.java


示例16: setUp

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    initMocks(this);

    clientBehaviorsMock = new HashMap<>();
    clientBehaviorsMock.put(existingButNotActiveEvent, notActiveBehaviors);
    clientBehaviorsMock.put(existingEvent, activeBehaviors);

    componentMock = new UIComponentBase() {

        @Override
        public Map<String, List<ClientBehavior>> getClientBehaviors() {
            return clientBehaviorsMock;
        }

        @Override
        public String getFamily() {
            return null;
        }
    };

    final AjaxBehavior disabledBehavior = new AjaxBehavior();
    disabledBehavior.setDisabled(true);
    notActiveBehaviors.add(disabledBehavior);

    activeBehaviors.add(new AjaxBehavior());
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:28,代码来源:ClientBehaviorResolverTest.java


示例17: decode

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public void decode(FacesContext context, UIComponent component) {
	Map<String, String> params = context.getExternalContext().getRequestParameterMap();
	String behaviorSource = params.get("javax.faces.source");
	String clientId = component.getClientId();

	if (behaviorSource != null && clientId.equals(behaviorSource)) {
		String behaviorEvent = params.get("javax.faces.behavior.event");

		if (behaviorEvent != null) {
			Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
			List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);

			if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
				for (ClientBehavior behavior : behaviorsForEvent)
					behavior.decode(context, component);
			}
		}

		// Decode behaviors for children, so we support activate ajax events on tabs
		// without accordion having to attach a tabChange listener
		for (UIComponent child : component.getChildren()) {
			if (child instanceof Tab) {
				List<ClientBehavior> activate = ((Tab) child).getClientBehaviors().get("activate");
				if (activate != null && !activate.isEmpty()) {
					if (((Tab) child).isActive())
						activate.forEach(b -> b.decode(context, child));
				}
			}
		}
	}
}
 
开发者ID:edvin,项目名称:tornadofaces,代码行数:32,代码来源:TabParentRenderer.java


示例18: encodeAjaxBehaviors

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public static <T extends UIComponent & ClientBehaviorHolder> JSONArray encodeAjaxBehaviors(
	FacesContext context, String name, T component) {
	List<ClientBehavior> behaviors = component.getClientBehaviors().get(name);
	if (behaviors != null && !behaviors.isEmpty()) {
		JSONArray array = new JSONArray();
		for (ClientBehavior behavior : behaviors) {
			if (behavior instanceof AjaxBehavior) {
				AjaxBehavior ab = (AjaxBehavior) behavior;

				JSONObject o = new JSONObject();
				Collection<String> execute = ab.getExecute();
				if (execute != null)
					o.put("execute", resolveIds(context, component, execute));

				Collection<String> render = ab.getRender();
				if (render != null)
					o.put("render", resolveIds(context, component, render));

				String delay = ab.getDelay();
				if (delay != null)
					o.put("delay", delay);

				if (ab.getOnevent() != null)
					o.put("onevent", ab.getOnevent());

				if (ab.getOnerror() != null)
					o.put("onerror", ab.getOnerror());

				array.put(o);
			}
		}
		return array;
	}
	return null;
}
 
开发者ID:edvin,项目名称:tornadofaces,代码行数:36,代码来源:ComponentUtils.java


示例19: getBehaviour

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Nonnull
private static <T extends ClientBehavior> T getBehaviour(Class<T> clazz,
		String id) {

	if (getContext() == null) {
		return createSimpleClass(clazz);
	}
	return (T) getApplication().createBehavior(id);
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:11,代码来源:KarakuComponentFactory.java


示例20: encodeEnd

import javax.faces.component.behavior.ClientBehavior; //导入依赖的package包/类
public void encodeEnd(FacesContext facesContext, UIComponent component)
    throws IOException
{
	
	  FacesContext ctx = FacesContext.getCurrentInstance();
String path = ctx.getExternalContext().getRequestContextPath();

      ResponseWriter writer = ctx.getResponseWriter();
      
    org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext,component,null);
    
    Map<String, List<ClientBehavior>> behaviors = null;
    if (component instanceof ClientBehaviorHolder)
    {
        behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
        if (!behaviors.isEmpty())
        {
            ResourceUtils.renderDefaultJsfJsInlineIfNecessary(facesContext, facesContext.getResponseWriter());
        }
    }
    
    if (component instanceof UIInput)
    {
        renderInput(facesContext, component);
    }
    else if (component instanceof UIOutput)
    {
        renderOutput(facesContext, component);
    }
    else
    {
        throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
    }
}
 
开发者ID:OWASP,项目名称:EJSF,代码行数:35,代码来源:EsapiTextRenderer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DocumentService类代码示例发布时间:2022-05-22
下一篇:
Java SimpleTestUsernamePasswordAuthenticationHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap