本文整理汇总了Java中javax.faces.el.ValueBinding类的典型用法代码示例。如果您正苦于以下问题:Java ValueBinding类的具体用法?Java ValueBinding怎么用?Java ValueBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueBinding类属于javax.faces.el包,在下文中一共展示了ValueBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import javax.faces.el.ValueBinding; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public String select()
{
FacesContext context = FacesContext.getCurrentInstance();
// The tableSelectOne is marked as required; so there'd better
// be a selected row - an exception will result here if there
// isn't. Is there some better code?
Iterator<Object> iterator = _table.getSelectedRowKeys().iterator();
Object rowKey = iterator.next();
Object oldRowKey = _table.getRowKey();
_table.setRowKey(rowKey);
ValueBinding binding = context.getApplication().
createValueBinding("#{row.symbol}");
Object value = binding.getValue(context);
RequestContext.getCurrentInstance().returnFromDialog(value, null);
_table.setRowKey(oldRowKey);
return null;
}
示例2: select
import javax.faces.el.ValueBinding; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public String select() {
try{
FacesContext context = FacesContext.getCurrentInstance();
Iterator<Object> iterator = _table.getSelectedRowKeys().iterator();
Object rowKey = iterator.next();
Object oldRowKey = _table.getRowKey();
_table.setRowKey(rowKey);
ValueBinding binding = context.getApplication().
createValueBinding("#{row.name}");
Object value = binding.getValue(context);
RequestContext.getCurrentInstance().returnFromDialog(value, null);
_table.setRowKey(oldRowKey);
}
catch (NoSuchElementException e){}
return null;
}
示例3: getLabelAsString
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Gets a string representation of the label. If the label
* is a ValueBinding, the expression is evaluated and the string
* value returned.
*/
public String getLabelAsString(FacesContext context)
{
Object label = getLabel();
if (label instanceof ValueExpression)
{
label = ((ValueExpression) label).getValue(context.getELContext());
}
else if (label instanceof ValueBinding)
{
label = ((ValueBinding) label).getValue(context);
}
if (label == null)
return null;
return label.toString();
}
示例4: getValueBinding
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
*/
@Override
public ValueBinding getValueBinding(String name)
{
if (name == null)
throw new NullPointerException();
PropertyKey key = getPropertyKey(name);
// Support standard RI behavior where getValueBinding()
// doesn't complain about being asked for a ValueBinding -
// but continue supporting strict behavior at FacesBean layer.
if (!key.getSupportsBinding())
return null;
return getFacesBean().getValueBinding(key);
}
示例5: getValueBinding
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Given a ValueExpression <code>ve</code>, return a ValueBinding.
* The returned ValueBinding will implement StateHolder and Serializable interfaces if
* <code>ve</code> implements these interfaces.
* @param ve The ValueExpression
* @return a ValueBinding equivalent to the ValueExpression
*/
public static ValueBinding getValueBinding(ValueExpression ve)
{
// if we previously wrapped a ValueBinding, unwrap it and return it, otherwise create the
// correct subclass of ValueBinding
if (ve instanceof ValueBindingValueExpression)
return ((ValueBindingValueExpression)ve).getValueBinding();
else if (ve instanceof StateHolder)
{
if (ve instanceof Serializable)
return new SerializableStateHolderValueExpressionValueBinding(ve);
else
return new StateHolderValueExpressionValueBinding(ve);
}
else if (ve instanceof Serializable)
{
return new SerializableValueExpressionValueBinding(ve);
}
else
{
return new ValueExpressionValueBinding(ve);
}
}
示例6: getValueExpression
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Given a ValueBinding <code>binding</code>, return a ValueExpression.
* The returned ValueExpression will implement StateHolder and Serializable interfaces if
* <code>ve</code> implements these interfaces.
* @param binding The ValueBinding
* @return a ValueExpression equivalent to the ValueBinding
*/
public static ValueExpression getValueExpression(ValueBinding binding)
{
// if we previously wrapped a ValueExpression, unwrap it and return it, otherwise create the
// correct subclass of ValueBindingValueExpression
if (binding instanceof ValueExpressionValueBinding)
return ((ValueExpressionValueBinding)binding).getValueExpression();
else if (binding instanceof StateHolder)
{
if (binding instanceof Serializable)
return new SerializableStateHolderValueBindingValueExpression(binding);
else
return new StateHolderValueBindingValueExpression(binding);
}
else if (binding instanceof Serializable)
{
return new SerializableValueBindingValueExpression(binding);
}
else
{
return new ValueBindingValueExpression(binding);
}
}
示例7: setValueBinding
import javax.faces.el.ValueBinding; //导入依赖的package包/类
@SuppressWarnings("deprecation")
final public void setValueBinding(PropertyKey key, ValueBinding binding)
{
ValueExpression ve;
if (binding == null)
{
ve = null;
}
else
{
ve = ValueBindingValueExpression.getValueExpression(binding);
}
setValueExpression(key, ve);
}
示例8: changeComponent
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("deprecation")
public void changeComponent(UIComponent uiComponent)
{
Map<String, Object> attributeMap = uiComponent.getAttributes();
// if the attributevalue is a ValueExpression or ValueBinding, use the
// appropriate setValueExpression/setValueBinding call and remove the
// current attribute value, if any, so that the ValueExpression/ValueBinding
// can take precedence
if (_attributeValue instanceof ValueExpression)
{
uiComponent.setValueExpression(_attributeName, (ValueExpression)_attributeValue);
attributeMap.remove(_attributeName);
}
else if (_attributeValue instanceof ValueBinding)
{
uiComponent.setValueBinding(_attributeName, (ValueBinding)_attributeValue);
attributeMap.remove(_attributeName);
}
else
{
attributeMap.put(_attributeName, _attributeValue);
}
}
示例9: testLocalValue
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Tests to make sure the setValue(), isLocalValueSet() contract is
* preserved.
*/
public void testLocalValue()
{
UIXInput input = new UIXInput();
assertFalse(input.isLocalValueSet());
assertNull(input.getLocalValue());
assertNull(input.getValue());
// setup a valueBinding
Mock mockBinding = mock(ValueBinding.class);
ValueBinding binding = (ValueBinding) mockBinding.proxy();
mockBinding.expects(atLeastOnce()).method("getValue").will(returnValue(Boolean.TRUE));// setupGetValue(Boolean.TRUE);
input.setValueBinding("value", binding);
assertFalse(input.isLocalValueSet());
assertNull(input.getLocalValue());
assertEquals(Boolean.TRUE, input.getValue());
// now set a local value
input.setValue("foo");
assertTrue(input.isLocalValueSet());
assertEquals("foo", input.getLocalValue());
assertEquals("foo", input.getValue());
}
示例10: setProperties
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
super.setProperties(component);
FacesContext context = getFacesContext();
if (value != null)
{
ValueBinding vb = context.getApplication().createValueBinding(value);
component.setValueBinding("value", vb);
}
if (var != null)
{
((UIData) component).setVar(var);
}
}
示例11: setAttribute
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Sets component attribute value - if a ValueBinding exists for that
* attribute, set through the binding; otherwise, set the value directly on
* the component.
*/
public static void setAttribute(FacesContext context, UIComponent component, String name,
Object value)
{
ValueBinding binding = component.getValueBinding(name);
if (binding != null)
{
try
{
binding.setValue(context, value);
} catch (IllegalArgumentException e)
{
// try setting the value as a String
binding.setValue(context, String.valueOf(value));
}
} else
{
component.getAttributes().put(name, value);
}
}
示例12: setValueBinding
import javax.faces.el.ValueBinding; //导入依赖的package包/类
public static void setValueBinding(UIComponent component, String attributeName,
String attributeValue)
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
ValueBinding vb = app.createValueBinding(attributeValue);
component.setValueBinding(attributeName, vb);
}
示例13: readValue
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* Read value.
*
* @return the string
*/
public String readValue () {
Object name = this.getAttributes().get(Options.value.name());
if(name == null) {
return "";
}
if(name instanceof ValueBinding) {
name = ((ValueBinding) name).getValue(this.getFacesContext());
if(name == null) {
return "";
}
else return name.toString();
}
else if(name instanceof String) {
return name.toString();
}
return "";
}
示例14: getMaxChildren
import javax.faces.el.ValueBinding; //导入依赖的package包/类
/**
* @return the maximum number of child descendants to be displayed, default maximum is 3.
*/
public int getMaxChildren()
{
ValueBinding vb = getValueBinding("maxChildren");
if (vb != null)
{
this.maxChildren = (Integer)vb.getValue(getFacesContext());
}
if (this.maxChildren != null)
{
return this.maxChildren.intValue();
}
else
{
// return default
return 3;
}
}
示例15: getCriteriaPageCursor
import javax.faces.el.ValueBinding; //导入依赖的package包/类
private PageCursor getCriteriaPageCursor() {
PageCursor pageCursor = null;
try {
Object pageCursorObj = this.getAttributes()
.get(ComponentMapKeys.criteriaCursor.name());
pageCursorObj = ((ValueBinding) pageCursorObj)
.getValue(this.getFacesContext());
if(pageCursorObj instanceof PageCursor) {
pageCursor = (PageCursor) pageCursorObj;
} else {
throw new ConfigurationException("Search Criteria PageCursor in JSF " +
"Paginator should be an" //$NON-NLS-1$
+ "instance of " + PageCursor.class.getCanonicalName()); //$NON-NLS-1$
}
} catch (Throwable t) {
// for backward compatibility
return this.getPageCursor();
}
return pageCursor;
}