01: package com.icesoft.faces.component.effect;
02:
03: import com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer;
04: import com.icesoft.faces.context.effects.*;
05: import org.apache.commons.logging.Log;
06: import org.apache.commons.logging.LogFactory;
07:
08: import javax.faces.context.FacesContext;
09: import javax.faces.component.UIComponent;
10: import java.io.IOException;
11:
12: public class ApplyEffectRenderer extends DomBasicRenderer {
13:
14: private static Log log = LogFactory
15: .getLog(ApplyEffectRenderer.class);
16:
17: public void encodeBegin(FacesContext facesContext,
18: UIComponent uiComponent) throws IOException {
19:
20: try {
21: String parentId = uiComponent.getParent().getClientId(
22: facesContext);
23: ApplyEffect af = (ApplyEffect) uiComponent;
24: Effect fx = EffectBuilder.build(af.getEffectType());
25: if (fx == null) {
26: log.error("No Effect for effectType ["
27: + af.getEffectType() + "]");
28: } else {
29: fx.setSequence(af.getSequence());
30: fx.setSequenceId(af.getSequenceNumber().intValue());
31: fx.setSubmit(af.getSubmit().booleanValue());
32: fx.setTransitory(af.getTransitory().booleanValue());
33: fx.setOptions(af.getOptions());
34:
35: if (af.getFire().booleanValue()) {
36: JavascriptContext.fireEffect(fx, uiComponent
37: .getParent(), facesContext);
38: if (af.getAutoReset().booleanValue())
39: af.setFire(Boolean.FALSE);
40: }
41: if (af.getEvent() != null) {
42: String event = af.getEvent();
43: LocalEffectEncoder.encodeLocalEffect(parentId, fx,
44: event, facesContext);
45: }
46: }
47: } catch (Exception e) {
48: log.error("Unexpected Exception in ApplyEffectRenderer", e);
49: }
50: }
51:
52: }
|