/** * @param config */ public UpdateActionListenerTagHandler(TagConfig config) { super(config); valueAttr = getRequiredAttribute("value"); propertyAttr = getRequiredAttribute("property"); converterAttr = getAttribute("converter"); }
public Object getValue() { if (_value != null) return _value; ValueBinding vb = getValueBinding(); if (vb != null) { FacesContext context = FacesContext.getCurrentInstance(); return vb.getValue(context); } return null; }
/** * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent) */ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { logger.debug("Apply called. Component: " + parent); ActionSource actionSource = (ActionSource) parent; if (sourceHasProperty(actionSource)) return; UpdateActionListener al = new UpdateActionListener(); Application app = ctx.getFacesContext().getApplication(); if (converterAttr != null) { Converter converter = app.createConverter(converterAttr .getValue(ctx)); al.setConverter(converter); } String value = valueAttr.getValue(); if (UIComponentTag.isValueReference(value)) al.setValueBinding(app.createValueBinding(valueAttr.getValue())); else al.setValue(value); al.setPropertyBinding(app.createValueBinding(propertyAttr.getValue())); actionSource.addActionListener(al); }
public void processAction(ActionEvent actionEvent) throws AbortProcessingException ValueBinding updateBinding = getPropertyBinding(); Object v = getValue(); if (v != null && v instanceof String) Converter converter = getConverter(); if (converter == null)
private boolean sourceHasProperty(ActionSource source) { for (ActionListener listener : source.getActionListeners()) { if (listener instanceof UpdateActionListener == false) continue; UpdateActionListener al = (UpdateActionListener) listener; if (al.getPropertyBinding().getExpressionString().equals( this.propertyAttr.getValue())) { logger.debug("Action listener already has a listener for " + this.propertyAttr.getValue()); return true; } } logger.debug("Action listener for property is not present. Property: " + this.propertyAttr.getValue()); return false; } }
/** * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, * javax.faces.component.UIComponent) */ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { logger.debug("Apply called. Component: " + parent); ActionSource actionSource = (ActionSource) parent; if (sourceHasProperty(actionSource)) return; UpdateActionListener al = new UpdateActionListener(); if (converterAttr != null) al.setConverter((Converter) converterAttr.getObject(ctx)); Application app = ctx.getFacesContext().getApplication(); ValueBinding vb = app.createValueBinding(valueAttr.getValue()); al.setValueBinding(vb); vb = app.createValueBinding(propertyAttr.getValue()); al.setPropertyBinding(vb); actionSource.addActionListener(al); }
private boolean sourceHasProperty(ActionSource source) { ActionListener[] listeners = source.getActionListeners(); for (int i = 0; i < listeners.length; i++) { ActionListener listener = listeners[i]; if (listener instanceof UpdateActionListener == false) continue; UpdateActionListener al = (UpdateActionListener) listener; if (al.getPropertyBinding().getExpressionString().equals( this.propertyAttr.getValue())) { logger.debug("Action listener already has a listener for " + this.propertyAttr.getValue()); return true; } } logger.debug("Action listener for property is not present. Property: " + this.propertyAttr.getValue()); return false; } }
UpdateActionListener al = new UpdateActionListener(); al.setPropertyBinding(application.createValueBinding(_property)); if (UIComponentTag.isValueReference(_value)) al.setValueBinding(application.createValueBinding(_value)); al.setValue(_value); al.setConverter(converter);
private boolean sourceHasProperty(ActionSource source) { ActionListener[] listeners = source.getActionListeners(); for (int i = 0; i < listeners.length; i++) { ActionListener listener = listeners[i]; if (listener instanceof UpdateActionListener == false) continue; UpdateActionListener al = (UpdateActionListener) listener; if (al.getPropertyBinding().getExpressionString().equals( this.propertyAttr.getValue())) { logger.debug("Action listener already has a listener for " + this.propertyAttr.getValue()); return true; } } logger.debug("Action listener for property is not present. Property: " + this.propertyAttr.getValue()); return false; } }
/** * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,javax.faces.component.UIComponent) */ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { logger.debug("Apply called. Component: " + parent); ActionSource actionSource = (ActionSource) parent; if (sourceHasProperty(actionSource)) return; UpdateActionListener al = new UpdateActionListener(); Application app = ctx.getFacesContext().getApplication(); if (converterAttr != null) { Converter converter = app.createConverter( converterAttr.getValue(ctx)); al.setConverter(converter); } String value = valueAttr.getValue(); if (UIComponentTag.isValueReference(value)) al.setValueBinding(app.createValueBinding( valueAttr.getValue())); else al.setValue(value); al.setPropertyBinding(app.createValueBinding( propertyAttr.getValue())); actionSource.addActionListener(al); }
UpdateActionListener listener = new UpdateActionListener(); if (isValueBinding) { listener.setValueBinding(a.createValueBinding( TagUtils.makeELExpression( getPaginatorELExpression() + "." + valueListener))); } else { listener.setValue(valueListener); listener.setPropertyBinding(a.createValueBinding( TagUtils.makeELExpression( getPaginatorELExpression() + "." + methodForListener )));
UpdateActionListener listener = new UpdateActionListener(); if (isValueBinding) { listener.setValueBinding(a.createValueBinding( TagUtils.makeELExpression( getPaginatorELExpression() + "." + valueListener))); } else { listener.setValue(valueListener); listener.setPropertyBinding(a.createValueBinding( TagUtils.makeELExpression( getPaginatorELExpression() + "." + methodForListener )));