本文整理汇总了Java中javax.faces.component.behavior.ClientBehavior类的典型用法代码示例。如果您正苦于以下问题:Java ClientBehavior类的具体用法?Java ClientBehavior怎么用?Java ClientBehavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientBehavior类属于javax.faces.component.behavior包,在下文中一共展示了ClientBehavior类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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'});");
}
示例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);
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}