[jboss-cvs] jboss-seam/src/ui/org/jboss/seam/ui ...
Gavin King
gavin.king at jboss.com
Mon Nov 13 23:59:39 EST 2006
User: gavin
Date: 06/11/13 23:59:39
Modified: src/ui/org/jboss/seam/ui HtmlLink.java JSF.java
Added: src/ui/org/jboss/seam/ui HtmlButton.java
HtmlOutputButton.java
Log:
JBSEAM-500 s:button
Revision Changes Path
1.22 +7 -86 jboss-seam/src/ui/org/jboss/seam/ui/HtmlLink.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HtmlLink.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlLink.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- HtmlLink.java 14 Nov 2006 03:47:35 -0000 1.21
+++ HtmlLink.java 14 Nov 2006 04:59:39 -0000 1.22
@@ -26,8 +26,6 @@
private String view;
private String action;
private String pageflow;
- private String style;
- private String buttonClass;
private String propagation = "default";
private String fragment;
private boolean disabled;
@@ -78,16 +76,7 @@
public void encodeBegin(FacesContext context) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
- if ( "button".equals(style) )
- {
- writer.startElement("input", this);
- writer.writeAttribute("type", "button", null);
- if (isDisabled(context)) writer.writeAttribute("disabled", true, "disabled");
- }
- else
- {
writer.startElement("a", this);
- }
writer.writeAttribute("id", getClientId(context), null);
String viewId;
@@ -186,69 +175,25 @@
encodedUrl += '#' + fragment;
}
- if ( "button".equals(style) )
- {
- String onclick = getOnclick();
- if (onclick==null)
- {
- onclick = "";
- }
- else if ( onclick.length()>0 && !onclick.endsWith(";") )
- {
- onclick += ";";
- }
- if ( !isDisabled(context) )
- {
- onclick += "location.href='" + encodedUrl + "'";
- }
- writer.writeAttribute("onclick", onclick, null);
- }
- else
- {
if ( !isDisabled(context) )
{
writer.writeAttribute("href", encodedUrl, null);
}
HTML.renderHTMLAttributes(writer, this, HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES);
- }
Object label = getValue();
- if (label!=null)
- {
- if ( "button".equals(style) )
- {
- writer.writeAttribute("value", label, "label");
- if (buttonClass!=null)
- {
- writer.writeAttribute("class", buttonClass, "buttonClass");
- }
writer.flush();
- }
- else
+ if (label!=null)
{
- writer.flush();
writer.writeText( label, null );
}
- }
- else
- {
- writer.flush();
- }
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
- ResponseWriter writer = context.getResponseWriter();
- if ( "button".equals(style) )
- {
- writer.endElement("input");
- }
- else
- {
- writer.endElement("a");
- }
+ context.getResponseWriter().endElement("a");
}
@SuppressWarnings("deprecation")
@@ -288,8 +233,6 @@
pageflow = (String) values[2];
propagation = (String) values[3];
action = (String) values[4];
- style = (String) values[5];
- buttonClass = (String) values[6];
disabled = (Boolean) values[7];
}
@@ -301,8 +244,6 @@
values[2] = pageflow;
values[3] = propagation;
values[4] = action;
- values[5] = style;
- values[6] = buttonClass;
values[7] = disabled;
return values;
}
@@ -337,26 +278,6 @@
this.action = action;
}
- public String getLinkStyle()
- {
- return style;
- }
-
- public void setLinkStyle(String style)
- {
- this.style = style;
- }
-
- public String getButtonClass()
- {
- return buttonClass;
- }
-
- public void setButtonClass(String buttonClass)
- {
- this.buttonClass = buttonClass;
- }
-
public String getFragment()
{
return fragment;
1.3 +12 -1 jboss-seam/src/ui/org/jboss/seam/ui/JSF.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JSF.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/JSF.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- JSF.java 2 Oct 2006 01:01:37 -0000 1.2
+++ JSF.java 14 Nov 2006 04:59:39 -0000 1.3
@@ -20,12 +20,13 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
/**
* Constant declarations for JSF tags
*
* @author Anton Koinov (latest modification by $Author: gavin $)
- * @version $Revision: 1.2 $ $Date: 2006/10/02 01:01:37 $
+ * @version $Revision: 1.3 $ $Date: 2006/11/14 04:59:39 $
*/
public class JSF
{
@@ -179,4 +180,14 @@
}
}
+ static String getStringValue(FacesContext context, ValueBinding vb)
+ {
+ Object value = vb.getValue(context);
+ if (value == null)
+ {
+ return null;
+ }
+ return value.toString();
+ }
+
}
1.1 date: 2006/11/14 04:59:39; author: gavin; state: Exp;jboss-seam/src/ui/org/jboss/seam/ui/HtmlButton.java
Index: HtmlButton.java
===================================================================
package org.jboss.seam.ui;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
import javax.faces.model.DataModel;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Pages;
public class HtmlButton extends HtmlOutputButton
{
public static final String COMPONENT_TYPE = "org.jboss.seam.ui.HtmlButton";
private String view;
private String action;
private String pageflow;
private String propagation = "default";
private String fragment;
private UISelection getSelection()
{
UIData parentUIData = getParentUIData();
if (parentUIData!=null)
{
if ( parentUIData.getValue() instanceof DataModel )
{
String dataModelExpression = parentUIData.getValueBinding("value").getExpressionString();
String dataModelName = dataModelExpression.substring(2, dataModelExpression.length()-1).replace('$','.');
UISelection uiSelection = new UISelection();
uiSelection.setDataModel(dataModelName);
uiSelection.setVar( parentUIData.getVar() );
return uiSelection;
}
else
{
return null;
}
}
else
{
return null;
}
}
public UIData getParentUIData()
{
UIComponent parent = this.getParent();
while (parent!=null)
{
if (parent instanceof UIData)
{
return (UIData) parent;
}
else
{
parent = parent.getParent();
}
}
return null;
}
@Override
public void encodeBegin(FacesContext context) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
writer.startElement("input", this);
writer.writeAttribute("type", "button", null);
if ( isDisabled() ) writer.writeAttribute("disabled", true, "disabled");
writer.writeAttribute("id", getClientId(context), null);
String viewId;
ValueBinding viewBinding = getValueBinding("view");
if (viewBinding!=null)
{
viewId = (String) viewBinding.getValue(context);
}
else if (view!=null)
{
viewId = view;
}
else
{
viewId = context.getViewRoot().getViewId();
}
String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
String encodedUrl = context.getExternalContext().encodeActionURL(url);
String characterEncoding = context.getResponseWriter().getCharacterEncoding();
boolean first = true;
Set<String> usedParameters = new HashSet<String>();
for (Object child: getChildren())
{
if (child instanceof UIParameter)
{
UIParameter uip = (UIParameter) child;
encodedUrl += getParameterString(characterEncoding, uip, first);
first = false;
usedParameters.add( uip.getName() );
}
}
if (viewId!=null)
{
Map<String, Object> pageParameters = Pages.instance().getConvertedParameters(context, viewId, usedParameters);
for ( Map.Entry<String, Object> me: pageParameters.entrySet() )
{
UIParameter uip = new UIParameter();
uip.setName( me.getKey() );
uip.setValue( me.getValue() );
encodedUrl += getParameterString(characterEncoding, uip, first);
first = false;
}
}
ValueBinding actionValueBinding = getValueBinding("action");
if (actionValueBinding!=null || action!=null)
{
UIAction uiAction = new UIAction();
uiAction.setValueBinding( "action", actionValueBinding );
uiAction.setAction(action);
encodedUrl += getParameterString(characterEncoding, uiAction, first);
first = false;
}
if ( "default".equals(propagation) || "join".equals(propagation) || "nest".equals(propagation) || "end".equals(propagation) )
{
if ( Conversation.instance().isLongRunning() || Conversation.instance().isNested() )
{
encodedUrl += getParameterString(characterEncoding, new UIConversationId(), first);
first = false;
encodedUrl += getParameterString(characterEncoding, new UIConversationIsLongRunning(), first);
}
}
if ( "join".equals(propagation) || "nest".equals(propagation) || "begin".equals(propagation) || "end".equals(propagation) )
{
UIConversationPropagation uiPropagation = new UIConversationPropagation();
uiPropagation.setType(propagation);
uiPropagation.setPageflow(pageflow);
encodedUrl += getParameterString(characterEncoding, uiPropagation, first);
first = false;
}
ValueBinding taskInstanceValueBinding = getValueBinding("taskInstance");
if (taskInstanceValueBinding!=null)
{
UITaskId uiTaskId = new UITaskId();
uiTaskId.setValueBinding("taskInstance", taskInstanceValueBinding);
encodedUrl += getParameterString(characterEncoding, uiTaskId, first);
first = false;
}
UISelection uiSelection = getSelection();
if (uiSelection!=null)
{
encodedUrl += getParameterString(characterEncoding, uiSelection, first);
first = false;
}
if (fragment!=null)
{
encodedUrl += '#' + fragment;
}
String onclick = getOnclick();
if (onclick==null)
{
onclick = "";
}
else if ( onclick.length()>0 && !onclick.endsWith(";") )
{
onclick += ";";
}
if ( !isDisabled() )
{
onclick += "location.href='" + encodedUrl + "'";
}
writer.writeAttribute("onclick", onclick, null);
HTML.renderHTMLAttributes(writer, this, HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
Object label = getValue();
if (label!=null)
{
writer.writeAttribute("value", label, "label");
}
writer.flush();
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
context.getResponseWriter().endElement("input");
}
@SuppressWarnings("deprecation")
private String getParameterString(String characterEncoding, UIParameter param, boolean first)
throws UnsupportedEncodingException
{
Object value = param.getValue();
String strValue = value==null ? "" : value.toString();
String encoded = characterEncoding==null ?
URLEncoder.encode(strValue) : //to work around what appears to be a bug in ADF
URLEncoder.encode(strValue, characterEncoding);
return (first ? '?' : '&') + param.getName() + '=' + encoded;
}
public String getView()
{
return view;
}
public void setView(String viewId)
{
this.view = viewId;
}
@Override
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
super.restoreState(context, values[0]);
view = (String) values[1];
pageflow = (String) values[2];
propagation = (String) values[3];
action = (String) values[4];
}
@Override
public Object saveState(FacesContext context) {
Object[] values = new Object[8];
values[0] = super.saveState(context);
values[1] = view;
values[2] = pageflow;
values[3] = propagation;
values[4] = action;
return values;
}
public String getPageflow()
{
return pageflow;
}
public String getPropagation()
{
return propagation;
}
public void setPageflow(String pageflow)
{
this.pageflow = pageflow;
}
public void setPropagation(String propagation)
{
this.propagation = propagation;
}
public String getAction()
{
return action;
}
public void setAction(String action)
{
this.action = action;
}
public String getFragment()
{
return fragment;
}
public void setFragment(String fragment)
{
this.fragment = fragment;
}
}
1.1 date: 2006/11/14 04:59:39; author: gavin; state: Exp;jboss-seam/src/ui/org/jboss/seam/ui/HtmlOutputButton.java
Index: HtmlOutputButton.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.seam.ui;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
/**
* see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
*
* @author Manfred Geiler (latest modification by $Author: gavin $)
* @version $Revision: 1.1 $ $Date: 2006/11/14 04:59:39 $
*/
public class HtmlOutputButton
extends UIOutput
{
//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
public static final String COMPONENT_TYPE = "javax.faces.HtmlCommandButton";
private static final String DEFAULT_RENDERER_TYPE = null;
private static final boolean DEFAULT_DISABLED = false;
private static final boolean DEFAULT_READONLY = false;
private static final String DEFAULT_TYPE = "button";
private String _accesskey = null;
private String _alt = null;
private String _dir = null;
private Boolean _disabled = null;
private String _image = null;
private String _lang = null;
private String _onblur = null;
private String _onchange = null;
private String _onclick = null;
private String _ondblclick = null;
private String _onfocus = null;
private String _onkeydown = null;
private String _onkeypress = null;
private String _onkeyup = null;
private String _onmousedown = null;
private String _onmousemove = null;
private String _onmouseout = null;
private String _onmouseover = null;
private String _onmouseup = null;
private String _onselect = null;
private Boolean _readonly = null;
private String _style = null;
private String _styleClass = null;
private String _tabindex = null;
private String _title = null;
private String _type = null;
public HtmlOutputButton()
{
setRendererType(DEFAULT_RENDERER_TYPE);
}
public void setAccesskey(String accesskey)
{
_accesskey = accesskey;
}
public String getAccesskey()
{
if (_accesskey != null) return _accesskey;
ValueBinding vb = getValueBinding("accesskey");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setAlt(String alt)
{
_alt = alt;
}
public String getAlt()
{
if (_alt != null) return _alt;
ValueBinding vb = getValueBinding("alt");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setDir(String dir)
{
_dir = dir;
}
public String getDir()
{
if (_dir != null) return _dir;
ValueBinding vb = getValueBinding("dir");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setDisabled(boolean disabled)
{
_disabled = Boolean.valueOf(disabled);
}
public boolean isDisabled()
{
if (_disabled != null) return _disabled.booleanValue();
ValueBinding vb = getValueBinding("disabled");
Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
return v != null ? v.booleanValue() : DEFAULT_DISABLED;
}
public void setImage(String image)
{
_image = image;
}
public String getImage()
{
if (_image != null) return _image;
ValueBinding vb = getValueBinding("image");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setLang(String lang)
{
_lang = lang;
}
public String getLang()
{
if (_lang != null) return _lang;
ValueBinding vb = getValueBinding("lang");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnblur(String onblur)
{
_onblur = onblur;
}
public String getOnblur()
{
if (_onblur != null) return _onblur;
ValueBinding vb = getValueBinding("onblur");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnchange(String onchange)
{
_onchange = onchange;
}
public String getOnchange()
{
if (_onchange != null) return _onchange;
ValueBinding vb = getValueBinding("onchange");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnclick(String onclick)
{
_onclick = onclick;
}
public String getOnclick()
{
if (_onclick != null) return _onclick;
ValueBinding vb = getValueBinding("onclick");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOndblclick(String ondblclick)
{
_ondblclick = ondblclick;
}
public String getOndblclick()
{
if (_ondblclick != null) return _ondblclick;
ValueBinding vb = getValueBinding("ondblclick");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnfocus(String onfocus)
{
_onfocus = onfocus;
}
public String getOnfocus()
{
if (_onfocus != null) return _onfocus;
ValueBinding vb = getValueBinding("onfocus");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnkeydown(String onkeydown)
{
_onkeydown = onkeydown;
}
public String getOnkeydown()
{
if (_onkeydown != null) return _onkeydown;
ValueBinding vb = getValueBinding("onkeydown");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnkeypress(String onkeypress)
{
_onkeypress = onkeypress;
}
public String getOnkeypress()
{
if (_onkeypress != null) return _onkeypress;
ValueBinding vb = getValueBinding("onkeypress");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnkeyup(String onkeyup)
{
_onkeyup = onkeyup;
}
public String getOnkeyup()
{
if (_onkeyup != null) return _onkeyup;
ValueBinding vb = getValueBinding("onkeyup");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnmousedown(String onmousedown)
{
_onmousedown = onmousedown;
}
public String getOnmousedown()
{
if (_onmousedown != null) return _onmousedown;
ValueBinding vb = getValueBinding("onmousedown");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnmousemove(String onmousemove)
{
_onmousemove = onmousemove;
}
public String getOnmousemove()
{
if (_onmousemove != null) return _onmousemove;
ValueBinding vb = getValueBinding("onmousemove");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnmouseout(String onmouseout)
{
_onmouseout = onmouseout;
}
public String getOnmouseout()
{
if (_onmouseout != null) return _onmouseout;
ValueBinding vb = getValueBinding("onmouseout");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnmouseover(String onmouseover)
{
_onmouseover = onmouseover;
}
public String getOnmouseover()
{
if (_onmouseover != null) return _onmouseover;
ValueBinding vb = getValueBinding("onmouseover");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnmouseup(String onmouseup)
{
_onmouseup = onmouseup;
}
public String getOnmouseup()
{
if (_onmouseup != null) return _onmouseup;
ValueBinding vb = getValueBinding("onmouseup");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setOnselect(String onselect)
{
_onselect = onselect;
}
public String getOnselect()
{
if (_onselect != null) return _onselect;
ValueBinding vb = getValueBinding("onselect");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setReadonly(boolean readonly)
{
_readonly = Boolean.valueOf(readonly);
}
public boolean isReadonly()
{
if (_readonly != null) return _readonly.booleanValue();
ValueBinding vb = getValueBinding("readonly");
Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
return v != null ? v.booleanValue() : DEFAULT_READONLY;
}
public void setStyle(String style)
{
_style = style;
}
public String getStyle()
{
if (_style != null) return _style;
ValueBinding vb = getValueBinding("style");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setStyleClass(String styleClass)
{
_styleClass = styleClass;
}
public String getStyleClass()
{
if (_styleClass != null) return _styleClass;
ValueBinding vb = getValueBinding("styleClass");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setTabindex(String tabindex)
{
_tabindex = tabindex;
}
public String getTabindex()
{
if (_tabindex != null) return _tabindex;
ValueBinding vb = getValueBinding("tabindex");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setTitle(String title)
{
_title = title;
}
public String getTitle()
{
if (_title != null) return _title;
ValueBinding vb = getValueBinding("title");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : null;
}
public void setType(String type)
{
_type = type;
}
public String getType()
{
if (_type != null) return _type;
ValueBinding vb = getValueBinding("type");
return vb != null ? JSF.getStringValue(getFacesContext(), vb) : DEFAULT_TYPE;
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[27];
values[0] = super.saveState(context);
values[1] = _accesskey;
values[2] = _alt;
values[3] = _dir;
values[4] = _disabled;
values[5] = _image;
values[6] = _lang;
values[7] = _onblur;
values[8] = _onchange;
values[9] = _onclick;
values[10] = _ondblclick;
values[11] = _onfocus;
values[12] = _onkeydown;
values[13] = _onkeypress;
values[14] = _onkeyup;
values[15] = _onmousedown;
values[16] = _onmousemove;
values[17] = _onmouseout;
values[18] = _onmouseover;
values[19] = _onmouseup;
values[20] = _onselect;
values[21] = _readonly;
values[22] = _style;
values[23] = _styleClass;
values[24] = _tabindex;
values[25] = _title;
values[26] = _type;
return values;
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
super.restoreState(context, values[0]);
_accesskey = (String)values[1];
_alt = (String)values[2];
_dir = (String)values[3];
_disabled = (Boolean)values[4];
_image = (String)values[5];
_lang = (String)values[6];
_onblur = (String)values[7];
_onchange = (String)values[8];
_onclick = (String)values[9];
_ondblclick = (String)values[10];
_onfocus = (String)values[11];
_onkeydown = (String)values[12];
_onkeypress = (String)values[13];
_onkeyup = (String)values[14];
_onmousedown = (String)values[15];
_onmousemove = (String)values[16];
_onmouseout = (String)values[17];
_onmouseover = (String)values[18];
_onmouseup = (String)values[19];
_onselect = (String)values[20];
_readonly = (Boolean)values[21];
_style = (String)values[22];
_styleClass = (String)values[23];
_tabindex = (String)values[24];
_title = (String)values[25];
_type = (String)values[26];
}
//------------------ GENERATED CODE END ---------------------------------------
}
More information about the jboss-cvs-commits
mailing list