/** * Determines if shadowed text is required. Default implementation is * simply to check for a null value. */ protected boolean needsShadowText(UICommand component) { return component.getValue() == null; }
/** * {@inheritDoc} * * @deprecated This has been replaced by {@link #setActionExpression(javax.el.MethodExpression)}. */ public void setAction(MethodBinding action) { MethodExpressionMethodBindingAdapter adapter; if (null != action) { adapter = new MethodExpressionMethodBindingAdapter(action); setActionExpression(adapter); } else { setActionExpression(null); } }
/** * @throws NullPointerException {@inheritDoc} */ @Override public void addActionListener(ActionListener listener) { addFacesListener(listener); }
protected boolean needsShadowText(UICommand component) { return component.getValue() == null && component.getChildCount() == 0; }
public void afterPhase(PhaseEvent event) { if (JsfUtils.isFlowRequest()) { FacesContext context = event.getFacesContext(); if (context.getExternalContext().getRequestParameterMap().containsKey("_eventId")) { UICommand eventSource = new UICommand(); eventSource.setTransient(true); eventSource.setParent(context.getViewRoot()); eventSource.setId("_eventId"); String eventId = context.getExternalContext().getRequestParameterMap().get("_eventId"); eventSource.setActionExpression(convertEventIdToMethodExpression(context, eventId)); context.getViewRoot().queueEvent(new ActionEvent(eventSource)); } } }
ValueBinding vb = context.getApplication().createValueBinding(value); component.setValueBinding(org.apache.myfaces.shared_impl.renderkit.JSFAttr.VALUE_ATTR, vb); ((UICommand)component).setValue(value);
protected Clicked wasClicked(final ValidationContext context, final UICommand command) { String clientId = command.getClientId(context.getFacesContext()); String value = context.getFacesContext().getExternalContext().getRequestParameterMap().get(clientId); if (value != null && (value.equals(clientId) || value.equals(command.getValue()))) { return new Clicked(true, clientId); } Clicked clicked = wasComponentWithRowIdClicked(context, command, clientId); if (clicked.isClicked()) { return clicked; } PartialViewContext partialContext = context.getFacesContext().getPartialViewContext(); if (partialContext != null && partialContext.isPartialRequest()) { // Is an ajax call partially processing the component tree Collection<String> execIds = partialContext.getExecuteIds(); return new Clicked(execIds.contains(clientId)); } return new Clicked(false); }
ResponseWriter writer = context.getResponseWriter(); assert(writer != null); Object value = ((UICommand) component).getValue(); if (value != null) { label = value.toString(); String imageSrc = (String) component.getAttributes().get("image"); writer.startElement("input", component); writeIdAttributeIfNecessary(context, writer, component); String clientId = component.getClientId(context); if (imageSrc != null) { writer.writeAttribute("type", "image", "type"); component.getAttributes().get("styleClass"); if (styleClass != null && styleClass.length() > 0) { writer.writeAttribute("class", styleClass, "styleClass");
if (!behaviors.isEmpty()) ResourceUtils.renderDefaultJsfJsInlineIfNecessary(facesContext, facesContext.getResponseWriter()); component.getClientId(facesContext), ((UICommand)component).getValue(), getStyle(facesContext, component), getStyleClass(facesContext, component));
public void broadcast(FacesEvent event) throws AbortProcessingException { super.broadcast(event); if (event instanceof ActionEvent) { FacesContext context = getFacesContext(); MethodBinding mb = getActionListener(); if (mb != null) { mb.invoke(context, new Object[] { event }); } ActionListener listener = context.getApplication() .getActionListener(); if (listener != null) { listener.processAction((ActionEvent) event); } } }
protected void validateUICommand(final ValidationContext validationContext, final UICommand command, final Clicked clicked) { validationContext.acceptParameter(command.getClientId(validationContext.getFacesContext()), command.getValue()); if (clicked.getParamName() != null) { validationContext.acceptParameter(clicked.getParamName(), validationContext.getFacesContext().getExternalContext().getRequestParameterMap().get(clicked.getParamName())); } // Check CommandLink's parameters for (UIComponent childComp : command.getChildren()) { if (childComp instanceof UIParameter) { UIParameter param = (UIParameter) childComp; processParam(validationContext, param, clicked); } } }
public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } if (!isDisabled(context, component) && !isCurrent( context, component )) { // use default rendering super.encodeChildren(context, component); } else { // render the text of the disabled/current link ourselves String label = ""; Object value = ((UICommand) component).getValue(); if (value != null) { label = value.toString(); } ResponseWriter writer = context.getResponseWriter(); writer.write(label); } }
MethodBinding mb = getActionListener(); if (mb != null) { mb.invoke(context, new Object[] { event }); context.getApplication().getActionListener(); if (listener != null) { listener.processAction((ActionEvent) event);
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException { super.encodeBegin(facesContext, component); //check for NP if (component instanceof UICommand) { renderCommandLinkStart(facesContext, component, component.getClientId(facesContext), ((UICommand) component).getValue(), getStyle(facesContext, component), getStyleClass(facesContext, component)); } else if (component instanceof UIOutput) { renderOutputLinkStart(facesContext, (UIOutput) component); } else { throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName()); } }
public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (UICommand.class.isAssignableFrom(component.getClass())) { ValueBinding valueBinding = component.getValueBinding(VALUE_PROP); //NOI18N UICommand command = (UICommand) component; Object value = command.getValue(); if (valueBinding != null && (value == null || value.toString().length() == 0)) { Object dummyValue = getDummyData(context, valueBinding); command.setValue(dummyValue); isTextSet = true; } else if (needsShadowText(command)) { command.setValue(getShadowText()); String styleClass = (String) component.getAttributes().get(STYLE_CLASS_PROP); component.getAttributes().put(STYLE_CLASS_PROP, addStyleClass(styleClass, UNINITITIALIZED_STYLE_CLASS)); isTextSet = true; isStyleSet = true; } } super.encodeBegin(context, component); }
protected void setValueProperty(UIComponent component, ValueExpression expression) { if (expression != null) { String value = expression.getExpressionString(); if (!expression.isLiteralText()) { component.setValueExpression("value", expression); } else if (component instanceof UICommand) { ((UICommand) component).setValue(value); } else if (component instanceof UIParameter) { ((UIParameter) component).setValue(value); } else if (component instanceof UISelectBoolean) { ((UISelectBoolean) component).setValue(Boolean.valueOf(value)); } else if (component instanceof UIGraphic) { ((UIGraphic) component).setValue(value); } // Since many input components are ValueHolders the special // components // must come first, ValueHolder is the last resort. else if (component instanceof ValueHolder) { ((ValueHolder) component).setValue(value); } else { component.getAttributes().put("value", value); } } }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { super.encodeEnd(context, component); if (isTextSet) { UICommand command = (UICommand)component; command.setValue(null); isTextSet = false; } if (isStyleSet) { String styleClass = (String) component.getAttributes().get(STYLE_CLASS_PROP); component.getAttributes().put(STYLE_CLASS_PROP, removeStyleClass(styleClass, UNINITITIALIZED_STYLE_CLASS)); isStyleSet = false; } }
public void afterPhase(PhaseEvent event) { FacesContext context = event.getFacesContext(); if (context.isPostback()) { UICommand component = findInvokedCommandComponent(context); if (component != null && component.getActionExpression() != null) { String methodExpression = component.getActionExpression().getExpressionString(); if (StringUtils.hasText(methodExpression)) { methodExpression = methodExpression.replace("#{", "").replace("}", ""); //restart the conversation if invoke method is called if (methodExpression.endsWith("invoke")) { String methodExpressionParts[] = methodExpression.split("\\."); if (methodExpressionParts != null && methodExpressionParts.length > 0) { ConversationManager conversationManager = ConversationManager.getInstance(false); Conversation conversation = conversationManager.getConversation(methodExpressionParts[0]); ConversationUtils.invalidateAndRestart(conversation); } } } } } }
public String getCommand() { MethodExpression expr = super.getActionExpression(); return expr != null ? expr.getExpressionString() : null; }
/** * @throws NullPointerException {@inheritDoc} */ @Override public void removeActionListener(ActionListener listener) { removeFacesListener(listener); }