|
Adding and Customizing Effects
This tutorial demonstrates how to add and customize effects in ICEfaces applications. Use the effects1 project located in your ICEfaces tutorial directory.
For more information about building and deploying your project, refer to the tutorials in Chapter 4 of the ICEfaces Getting Started Guide.
<ice:form> <ice:commandButton value="Invoke" action="#{effectBean.invokeEffect}"/> <ice:outputText value="Effect Test" effect="#{effectBean.textEffect}"/> </ice:form>private Effect textEffect; public Effect getTextEffect(){ return textEffect; } public void setTextEffect(Effect effect){ textEffect = effect; } public String invokeEffect(){ textEffect = new Highlight(); return null; }http://localhost:8080/effects1The following effects can be used in your ICEfaces application:
The following steps demonstrate how you can modify several different effects.
1. In the EffectBean, add a Boolean flag, and then toggle the color from yellow to red on each click of the command button.
private boolean flag; public String invokeEffect(){ if(flag){ textEffect = new Highlight("#FF0000"); }else{ textEffect = new Highlight("#FFFF00"); } flag = !flag; return null; }http://localhost:8080/effects1Note: Each effect is fired once per instance. Each time you want to fire an effect, it must be with a new effect instance object or you can set the fired flag to false.
For example, Effect.setFired(false);
public String invokeEffect(){ if(flag){ textEffect = new Highlight(); }else{ textEffect = new Pulsate(); } flag = !flag; return null; }http://localhost:8080/effects15. Effects can also be invoked locally. Change the effect attribute from effect to onmouseovereffect.
<ice:outputText value="Effect Test" onmouseovereffect="#{effectBean.textEffect}"/>http://localhost:8080/effects17. Click the invoke button and then move the mouse over the text. The text will highlight immediately.
Copyright 2005-2009. ICEsoft Technologies, Inc. |