You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/08/18 15:00:50 UTC
svn commit: r432567 - in /myfaces/tomahawk/trunk/sandbox/core/src/main:
java/org/apache/myfaces/custom/script/ tld/ tld/entities/
Author: imario
Date: Fri Aug 18 06:00:50 2006
New Revision: 432567
URL: http://svn.apache.org/viewvc?rev=432567&view=rev
Log:
allow to embed content in script tag. This allows you to use
<h:outputText in your scriptlet - e.g. access to bean values through el
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_script_attributes.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java?rev=432567&r1=432566&r2=432567&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java Fri Aug 18 06:00:50 2006
@@ -34,8 +34,9 @@
private String src = null;
private String type = HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT;
+ private String language = null;
- // ------------------------------------------------------------ Constructor
+ // ------------------------------------------------------------ Constructor
public Script() {
setRendererType(DEFAULT_RENDERER_TYPE);
}
@@ -73,25 +74,35 @@
this.type = type;
}
- // ------------------------------------------------------------ StateHolder
+ public String getLanguage() {
+ if (language != null) return language;
+ ValueBinding vb = getValueBinding("language");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ // ------------------------------------------------------------ StateHolder
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
src = (String) values[1];
type = (String) values[2];
-
+ language = (String) values[3];
}
public Object saveState(FacesContext context) {
- Object values[] = new Object[6];
- values[0] = super.saveState(context);
- values[1] = src;
- values[2] = type;
- return values;
-
+ return new Object[]
+ {
+ super.saveState(context),
+ src,
+ type,
+ language
+ };
}
-
-
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java?rev=432567&r1=432566&r2=432567&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java Fri Aug 18 06:00:50 2006
@@ -30,17 +30,34 @@
*/
public class ScriptRenderer extends HtmlRenderer {
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ if ((context == null) || (component == null)) {
+ throw new NullPointerException();
+ }
+ Script script = (Script) component;
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ if (script.getSrc() != null)
+ {
+ writer.writeAttribute(HTML.SRC_ATTR, context.getApplication().getViewHandler().getResourceURL(context, script.getSrc()), null);
+ }
+ if (script.getType() != null)
+ {
+ writer.writeAttribute(HTML.TYPE_ATTR, script.getType(), null);
+ }
+ if (script.getLanguage() != null)
+ {
+ writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR, script.getLanguage(), null);
+ }
+ writer.writeText("",null);
+ }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- if ((context == null) || (component == null)) {
- throw new NullPointerException();
- }
- Script script = (Script) component;
- ResponseWriter writer = context.getResponseWriter();
+ if ((context == null) || (component == null)) {
+ throw new NullPointerException();
+ }
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.SRC_ATTR, context.getApplication().getViewHandler().getResourceURL(context, script.getSrc()), null);
- writer.writeAttribute(HTML.TYPE_ATTR, script.getType(), null);
- writer.writeText("",null);
+ ResponseWriter writer = context.getResponseWriter();
writer.endElement(HTML.SCRIPT_ELEM);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java?rev=432567&r1=432566&r2=432567&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java Fri Aug 18 06:00:50 2006
@@ -28,9 +28,9 @@
private String src = null;
private String type = null;
-
-
- // ------------------------------------------------------------ UIComponentTags
+ private String language = null;
+
+ // ------------------------------------------------------------ UIComponentTags
public String getComponentType() {
return Script.COMPONENT_TYPE;
@@ -39,7 +39,7 @@
public String getRendererType() {
return "org.apache.myfaces.Script";
}
-
+
public void release() {
super.release();
@@ -47,15 +47,16 @@
type = null;
}
-
+
protected void setProperties(UIComponent component) {
super.setProperties(component);
setStringProperty(component, HTML.SRC_ATTR, src);
setStringProperty(component, HTML.TYPE_ATTR, type);
- }
+ setStringProperty(component, HTML.SCRIPT_LANGUAGE_ATTR, language);
+ }
+
-
// ------------------------------------------------------------ setter
public void setSrc(String src) {
this.src = src;
@@ -64,5 +65,10 @@
this.type = type;
}
-
+ public String getLanguage() {
+ return language;
+ }
+ public void setLanguage(String language) {
+ this.language = language;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_script_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_script_attributes.xml?rev=432567&r1=432566&r2=432567&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_script_attributes.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_script_attributes.xml Fri Aug 18 06:00:50 2006
@@ -14,4 +14,11 @@
type of script source
</description>
</attribute>
-
\ No newline at end of file
+ <attribute>
+ <name>language</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ script language
+ </description>
+ </attribute>
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=432567&r1=432566&r2=432567&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Fri Aug 18 06:00:50 2006
@@ -184,7 +184,7 @@
<tag>
<name>script</name>
<tag-class>org.apache.myfaces.custom.script.ScriptTag</tag-class>
- <body-content>empty</body-content>
+ <body-content>JSP</body-content>
<display-name>Script component</display-name>
<description>Adds (java)script to the browser</description>
&ui_component_attributes;
@@ -209,7 +209,7 @@
<tag-class>org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBoxTag</tag-class>
<body-content>JSP</body-content>
<description>
- Refreshes contents through an ajax call when the parent combo box's value is changed
+ Refreshes contents through an ajax call when the parent combo box's value is changed
</description>
&standard_select_one_listbox_attributes;
&ext_escape_attribute;
@@ -466,18 +466,18 @@
<name>convertStringUtils</name>
<tag-class>org.apache.myfaces.custom.convertStringUtils.StringUtilsConverterTag</tag-class>
<display-name>StringUtils Converter</display-name>
- <description>Converts the format of a string</description>
+ <description>Converts the format of a string</description>
<attribute>
<name>appendEllipsesDuringInput</name>
<required>false</required>
<description>Boolean value determining if data should be truncated with ellipses during input conversion. Default = false</description>
- </attribute>
+ </attribute>
<attribute>
<name>appendEllipsesDuringOutput</name>
<required>false</required>
<description>Boolean value determining if data should be truncated with ellipses during output conversion. Default = false</description>
- </attribute>
+ </attribute>
<attribute>
<name>format</name>
<required>false</required>
@@ -492,7 +492,7 @@
<name>trim</name>
<required>false</required>
<description>Boolean value determining is the string should be trimmed before any other formatting takes place. Default = false</description>
- </attribute>
+ </attribute>
</tag>
<tag>
@@ -960,8 +960,8 @@
<rtexprvalue>false</rtexprvalue>
<type>java.lang.Boolean</type>
</attribute>
-
-
+
+
<attribute>
<name>baseScriptUri</name>
<required>false</required>
@@ -1058,7 +1058,7 @@
<type>java.lang.String</type>
<description>Specify the id of the dom element where the value should be put in.
This value is also included in the suggested table, but only in a hidden
- span element following the span for the label in one row.
+ span element following the span for the label in one row.
</description>
</attribute>
<attribute>
@@ -1067,7 +1067,7 @@
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
<description>To provide a second value in form of a label. Usage like SelectItem.
- Label is brought to client in a hidden span element near the value.
+ Label is brought to client in a hidden span element near the value.
</description>
</attribute>
</tag>
@@ -1076,7 +1076,7 @@
<tag-class>org.apache.myfaces.custom.ifmessage.IfMessageTag</tag-class>
<body-content>JSP</body-content>
<display-name>ifMessage component</display-name>
- <description>Provide a component that will optionally render its children if the specified
+ <description>Provide a component that will optionally render its children if the specified
component(s) specified has a message.</description>
<attribute>
<name>for</name>
@@ -1086,7 +1086,7 @@
<description></description>
</attribute>
</tag>
-
+
<!-- fishEyeList -->
<tag>
<name>fishEyeNavigationMenu</name>
@@ -1098,8 +1098,8 @@
&faces_rendered_attribute;
&html_fisheye_list_attributes;
- </tag>
-
+ </tag>
+
<!-- timed notifier -->
<tag>
<name>timedNotifier</name>
@@ -1163,15 +1163,15 @@
<description>
This tag creates a number formatting converter and associates it
with the nearest parent UIComponent.
-
+
It uses either the manually set <code>destType</code> or the value binding
to determine the correct destination type to convert the number to.
-
+
Unless otherwise specified, all attributes accept static values or EL expressions.
</description>
&convertNumber_attributes;
&ui_convertNumber_attributes;
-
+
</tag>
<tag>