Author: a.izobov
Date: 2007-06-11 09:54:23 -0400 (Mon, 11 Jun 2007)
New Revision: 1118
Modified:
trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-49 fixed
Modified: trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml
===================================================================
--- trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml 2007-06-11 13:33:51
UTC (rev 1117)
+++ trunk/richfaces/tabPanel/src/main/config/component/tabPanel.xml 2007-06-11 13:54:23
UTC (rev 1118)
@@ -203,6 +203,22 @@
<name>active</name>
<classname>boolean</classname>
</property>
+ <property>
+ <name>ontableave</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on the tab which has been left
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>ontabenter</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on the tab which has been entered
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
</component>
<renderer generate="true">
<template>tabHeader.jspx</template>
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
===================================================================
---
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-06-11
13:33:51 UTC (rev 1117)
+++
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-06-11
13:54:23 UTC (rev 1118)
@@ -69,10 +69,11 @@
if (!disabled) {
if (clientSide) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE,
"RichFaces.switchTab('" + pane.getClientId(context) +
"','" + clientId + "','" +
getUtils().formatValue(context, pane, tab.getName()) + "');",
"switchScript");
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "if
(RichFaces.onTabChange('"+pane.getClientId(context)+"','"+clientId+"'))
RichFaces.switchTab('" + pane.getClientId(context) + "','" +
clientId + "','" + getUtils().formatValue(context, pane, tab.getName())
+ "');", "switchScript");
} else {
String activeCheck = "if (RichFaces.isTabActive('" +
clientId + LABEL_SUFFIX + "')) return false;";
-
+ String eventCheck = " if
(!RichFaces.onTabChange('"+pane.getClientId(context)+"','"+clientId+"'))
return false;";
+
if (ajax) {
JSFunction function = AjaxRendererUtils.buildAjaxFunction(tab,
context);
@@ -84,14 +85,14 @@
function.appendScript(buffer);
buffer.append("; return false; this.onclick = null;");
String script = buffer.toString();
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script,
null);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck +
eventCheck + script, null);
} else {
StringBuffer script = new StringBuffer("var _formName =
A4J.findForm(this).id; var _paramName = '" + clientId +
"_server_submit'; var _params = new Object(); _params[_paramName] = _paramName;
_JSFFormSubmit('");
script.append(clientId);
script.append("', _formName, null, _params);");
script.append("this.onclick = null;
_clearJSFFormParameters(_formName, null, [_paramName]);");
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck +
script.toString()
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck +
eventCheck + script.toString()
/* "RichFaces.submitTab(this,'"+clientId +
"_inp" +"','"+pane.getClientId(context)+"');"*/,
null);
}
}
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
---
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-06-11
13:33:51 UTC (rev 1117)
+++
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-06-11
13:54:23 UTC (rev 1118)
@@ -109,7 +109,10 @@
private final JSReference JSR_CELL_ACTIVE_CLASS = new
JSReference("cellActiveClass");
private final JSReference JSR_CELL_INACTIVE_CLASS = new
JSReference("cellInactiveClass");
-
+ private final JSReference JSR_NAME = new JSReference("name");
+ private final JSReference JSR_ONTABLEAVE = new
JSReference("ontableave");
+ private final JSReference JSR_ONTABENTER = new
JSReference("ontabenter");
+
public Object collectTabInfo(FacesContext context, UITab tab) {
Map info = new HashMap();
info.put(JSR_ID, tab.getClientId(context));
@@ -119,6 +122,10 @@
info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
+ info.put(JSR_NAME, tab.getName());
+ info.put(JSR_ONTABLEAVE, tab.getAttributes().get("ontableave"));
+ info.put(JSR_ONTABENTER, tab.getAttributes().get("ontabenter"));
+
return info;
}
};
Modified:
trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
===================================================================
---
trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-06-11
13:33:51 UTC (rev 1117)
+++
trunk/richfaces/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-06-11
13:54:23 UTC (rev 1118)
@@ -135,3 +135,31 @@
RichFaces._shouldHoverTab = function(tab) {
return (tab.className.indexOf('dr-tbpnl-tb-act') < 0);
}
+
+RichFaces.onTabChange = function(pane,tab) {
+ var labelSuffix = "_lbl";
+ var tabs = RichFaces.panelTabs[pane];
+ var lastActive, newActive;
+ if (tabs) {
+ for( var i=0; i<tabs.length; i++){
+ if (lastActive && newActive) break;
+ var tabId = tabs[i].id;
+ if (tabId == tab)
+ newActive = tabs[i];
+ if (RichFaces.isTabActive(tabId +labelSuffix))
+ lastActive = tabs[i];
+ }
+ }
+ if (lastActive && newActive) {
+ if (lastActive.ontableave && lastActive.ontableave != "") {
+ var func = new
Function("leftTabName","enteredTabName",lastActive.ontableave);
+ if (!func(lastActive.name,newActive.name)) return false;
+ }
+ if (newActive.ontabenter && newActive.ontabenter != "") {
+ var func = new
Function("leftTabName","enteredTabName",newActive.ontabenter);
+ return func(lastActive.name,newActive.name);
+ }
+ }
+ return true;
+}
+
Modified: trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx 2007-06-11 13:33:51 UTC (rev
1117)
+++ trunk/richfaces/tabPanel/src/main/templates/tabPanel.jspx 2007-06-11 13:54:23 UTC (rev
1118)
@@ -45,15 +45,15 @@
<f:call name="encodeTabs" />
</tr>
</table>
- <c:if test="#{clientSide}">
- <div style="display: none;">
+ <div style="display: none;">
+ <c:if test="#{clientSide}">
<input type="hidden"
id="#{clientId}_input"
name="#{clientId}"
value="#{this:getValueAsString(context, component)}" />
- <f:call name="encodeTabsScript" />
- </div>
- </c:if>
+ </c:if>
+ <f:call name="encodeTabsScript" />
+ </div>
<f:call name="utils.encodeEndFormIfNessesary" />
</td>
</tr>