Author: ilya_shaikovsky
Date: 2008-09-25 08:03:02 -0400 (Thu, 25 Sep 2008)
New Revision: 10556
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/TabAjaxListener.java
Modified:
trunk/samples/richfaces-demo/src/main/webapp/templates/include/sourceview.xhtml
Log:
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/TabAjaxListener.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/TabAjaxListener.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/TabAjaxListener.java 2008-09-25
12:03:02 UTC (rev 10556)
@@ -0,0 +1,53 @@
+package org.richfaces.demo.validation;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+import org.richfaces.component.UITab;
+import org.richfaces.component.UITabPanel;
+
+public class TabAjaxListener implements AjaxListener{
+
+ public void processAjax(AjaxEvent event) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ //Conversion/Validation Messages appears
+ if (context.getMaximumSeverity() != null){
+ //getting all the components with messages
+ Iterator<String> ids = context.getClientIdsWithMessages();
+ if(ids.hasNext()) {
+ // getting element id as string
+ String id = ids.next();
+ // getting component by it's id
+ UIViewRoot view = context.getViewRoot();
+ UIComponent cmp = (UIComponent)view.findComponent(id);
+ UIComponent parentTab = this.findParentTabComponent(cmp);
+ if (parentTab != null){
+ UIComponent parentTabPanel = parentTab.getParent();
+ ((UITabPanel)parentTabPanel).setSelectedTab(((UITab)parentTab).getName());
+ }
+ }
+ }
+ }
+ public UIComponent findParentTabComponent(UIComponent component)
+ { // need to find and return parent org.richfaces.Tab component
+
+ // searching for parent org.richfaces.Tab component
+ UIComponent parent = component.getParent();
+ while(!"org.richfaces.Tab".equals(parent.getFamily()))
+ {
+ parent = parent.getParent();
+
+ if(parent == null || parent.equals("javax.faces.ViewRoot"))
+ { // if parent = javax.faces.ViewRoot or null(which is parent() of
javax.faces.ViewRoot) - we should break while cycle
+ parent = null;
+ break;
+ }
+ }
+ return parent;
+ }
+}
Modified: trunk/samples/richfaces-demo/src/main/webapp/templates/include/sourceview.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/templates/include/sourceview.xhtml 2008-09-25
11:41:48 UTC (rev 10555)
+++
trunk/samples/richfaces-demo/src/main/webapp/templates/include/sourceview.xhtml 2008-09-25
12:03:02 UTC (rev 10556)
@@ -50,7 +50,7 @@
<a4j:outputPanel id="hide2" styleClass="viewsourcelooklink"
style="display:none">
<rich:effect for="hide2" event="onclick"
type="BlindUp" targetId="source1" params="id:'source1',
duration:1.0" />
<rich:effect for="hide2" event="onclick"
type="Appear" targetId="look" params="delay:1.5,
duration:0.5" />
- <rich:effect for="hide2" event="onclick" type="Fade"
targetId="hide2" params="delay:0.0, duration:0.1" />
+ <rich:effect for="hide2" event="onclick" type="Fade"
targetId="hide2" params="delay:0.0, duration:0.0" />
<h:outputText style="padding-right:5px" value="Hide"/>
</a4j:outputPanel>
@@ -75,7 +75,7 @@
<a4j:outputPanel id="hide" styleClass="viewsourcehidelink">
<rich:effect for="hide" event="onclick"
type="BlindUp" targetId="source1" params="id:'source1',
duration:1.0" />
<rich:effect for="hide" event="onclick"
type="Appear" targetId="look" params="delay:1.5,
duration:0.5" />
- <rich:effect for="hide" event="onclick" type="Fade"
targetId="hide2" params="delay:0.0, duration:0.1" />
+ <rich:effect for="hide" event="onclick" type="Fade"
targetId="hide2" params="delay:0.0, duration:0.0" />
<h:outputText style="padding-right:5px" value="<<Hide
Source"/>
</a4j:outputPanel>
Show replies by date