Author: ayanul
Date: 2007-11-02 09:38:48 -0400 (Fri, 02 Nov 2007)
New Revision: 3716
Added:
branches/3.1.x/test-applications/facelets/src/main/java/util/phaseTracker/PhaseTracker.java
branches/3.1.x/test-applications/facelets/src/main/java/util/skins/Skins.java
Log:
add util class (PhaseTracker.java, Skins.java)
Added:
branches/3.1.x/test-applications/facelets/src/main/java/util/phaseTracker/PhaseTracker.java
===================================================================
---
branches/3.1.x/test-applications/facelets/src/main/java/util/phaseTracker/PhaseTracker.java
(rev 0)
+++
branches/3.1.x/test-applications/facelets/src/main/java/util/phaseTracker/PhaseTracker.java 2007-11-02
13:38:48 UTC (rev 3716)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package util.phaseTracker;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * @author AYanul
+ *
+ */
+public class PhaseTracker implements PhaseListener {
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public void afterPhase(PhaseEvent arg0) {
+ System.out.println("PhaseTracker.afterPhase()" + arg0.getPhaseId());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public void beforePhase(PhaseEvent arg0) {
+ System.out.println("PhaseTracker.beforePhase()" + arg0.getPhaseId());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Added: branches/3.1.x/test-applications/facelets/src/main/java/util/skins/Skins.java
===================================================================
--- branches/3.1.x/test-applications/facelets/src/main/java/util/skins/Skins.java
(rev 0)
+++
branches/3.1.x/test-applications/facelets/src/main/java/util/skins/Skins.java 2007-11-02
13:38:48 UTC (rev 3716)
@@ -0,0 +1,71 @@
+package util.skins;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UISelectItem;
+import javax.faces.component.UISelectOne;
+import javax.faces.component.html.HtmlSelectOneRadio;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
+ *
+ */
+public class Skins {
+
+ private String[] skinsArray = new String[] { "blueSky", "classic",
+ "deepMarine", "DEFAULT", "emeraldTown",
"japanCherry", "ruby",
+ "wine", "plain" };
+
+ private String defaultSkin = "deepMarine";
+
+ private String skin = defaultSkin;
+
+ private UISelectOne createComponent() {
+ UISelectOne selectOne = new HtmlSelectOneRadio();
+ selectOne.setValue(skin);
+
+ for (int i = 0; i < skinsArray.length; i++) {
+ String skinName = skinsArray[i];
+
+ UISelectItem item = new UISelectItem();
+ item.setItemLabel(skinName);
+ item.setItemValue(skinName);
+ item.setId("skinSelectionFor_" + skinName);
+
+ selectOne.getChildren().add(item);
+ }
+
+ return selectOne;
+ }
+
+ public String getSkin() {
+ return skin;
+ }
+
+ public UIComponent getComponent() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Map requestMap = facesContext.getExternalContext().getRequestMap();
+ Object object = requestMap.get("SkinBean");
+ if (object != null) {
+ return (UISelectOne) object;
+ }
+
+ UISelectOne selectOne = createComponent();
+ requestMap.put("SkinBean", selectOne);
+ return selectOne;
+ }
+
+ public void setComponent(UIComponent component) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Map requestMap = facesContext.getExternalContext().getRequestMap();
+ requestMap.put("SkinBean", component);
+ }
+
+ public String change() {
+ UISelectOne selectOne = (UISelectOne) getComponent();
+ skin = (String) selectOne.getValue();
+ return null;
+ }
+}
Show replies by date