本文整理匯總了Java中javax.faces.component.UIInput.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java UIInput.setValue方法的具體用法?Java UIInput.setValue怎麽用?Java UIInput.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIInput
的用法示例。
在下文中一共展示了UIInput.setValue方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resetUIInputChildren
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Reset the values of all UIInput children. This might be necessary after a
* validation error to successfully process an AJAX request. See [Bug 5449]
* and http://wiki.apache.org/myfaces/ClearInputComponents
*
* @param uiComponent
* the root component to be processed.
*/
public static void resetUIInputChildren(UIComponent uiComponent) {
if (uiComponent != null) {
List<UIComponent> children = uiComponent.getChildren();
for (UIComponent child : children) {
if (child instanceof UIInput) {
UIInput uiInput = (UIInput) child;
uiInput.setSubmittedValue(null);
uiInput.setValue(null);
uiInput.setLocalValueSet(false);
} else {
resetUIInputChildren(child);
}
}
}
}
示例2: unBind
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Triggered on the save event from the metadata editor.
* <p/>
* On this event, either HtmlSelectOneMenu input value or the HtmlInputText
* value is propagated to the parameter's singleValue (depending on the
* whether or not the user has selected the "Other" option).
* @param context the UI context
* @param editorForm the Faces HtmlForm for the metadata editor
* @param parameter the associated parameter
* @throws SchemaException if an associated Faces UIComponent cannot be located
*/
@Override
public void unBind(UiContext context,
UIComponent editorForm,
Parameter parameter)
throws SchemaException {
UIInput menu = findInputComponent(context,editorForm);
UIInput text = getOtherComponent().findInputComponent(context,editorForm);
String sMenuValue = getInputValue(menu);
String sTextValue = Val.chkStr(getInputValue(text));
text.setValue(sTextValue);
if (sMenuValue.equalsIgnoreCase(getOtherCodeKey())) {
parameter.getContent().getSingleValue().setValue(sTextValue);
if (text instanceof HtmlInputText) {
((HtmlInputText)text).setStyle("visibility:visible;");
}
} else {
parameter.getContent().getSingleValue().setValue(sMenuValue);
if (text instanceof HtmlInputText) {
((HtmlInputText)text).setStyle("visibility:hidden;");
}
}
}
示例3: unBind
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Triggered on the save event from the metadata editor.
* <p/>
* On this event, the multiple values associated with the parameter
* (parameter.getMultipleValues()) are generated from the delimited
* input string.
* @param context the UI context
* @param editorForm the Faces HtmlForm for the metadata editor
* @param parameter the associated parameter
* @throws SchemaException if an associated Faces UIComponent cannot be located
*/
@Override
public void unBind(UiContext context,
UIComponent editorForm,
Parameter parameter)
throws SchemaException {
// tokenize the delimited input string
UIInput input = findInputComponent(context,editorForm);
String sDelimited = Val.chkStr(getInputValue(input));
sDelimited = sDelimited.replaceAll("(\r\n|\r|\n|\n\r)",getDelimiter());
String[] tokens = Val.tokenize(sDelimited,getDelimiter());
// clear current values, append each token to the values collection
parameter.getContent().clearAllValues();
ContentValues values = parameter.getContent().getMultipleValues();
for (String sValue: tokens) {
if (sValue.length() > 0) {
values.add(new ContentValue(sValue));
}
}
input.setValue(makeDelimitedValue(parameter));
}
示例4: encodeBegin
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Performs the encoding - pulling the value out from the model and storing it in the UI
* @param context - context
* @throws IOException - IOException
*/
@Override
public void encodeBegin(FacesContext context) throws IOException {
PhoneNumber phone = (PhoneNumber)getValue();
UIInput areaCode = (UIInput)findComponent(AREA_CODE);
UIInput prefix = (UIInput)findComponent(PREFIX);
UIInput lineNumber = (UIInput)findComponent(LINE_NUMBER);
if(phone != null) {
areaCode.setValue(phone.getAreaCode());
prefix.setValue(phone.getPrefix());
lineNumber.setValue(phone.getLineNumber());
}
super.encodeBegin(context);
}
示例5: unBind
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Triggered on the save event from the metadata editor.
* <p/>
* On this event, the array of input values are used to generate
* the parameter's multiple values (parameter.getMultipleValues()).
* @param context the UI context
* @param editorForm the Faces HtmlForm for the metadata editor
* @param parameter the associated parameter
* @throws SchemaException if an associated Faces UIComponent cannot be located
*/
@Override
public void unBind(UiContext context,
UIComponent editorForm,
Parameter parameter)
throws SchemaException {
// clear current values
parameter.getContent().clearAllValues();
ContentValues values = parameter.getContent().getMultipleValues();
// find input text component
String sIdPfx = getFacesId();
for (int i=0;i<getArraySize();i++) {
String sId = sIdPfx+"-v"+i;
UIComponent component = editorForm.findComponent(sId);
if ((component != null) && (component instanceof UIInput)) {
UIInput input = (UIInput)component;
String sValue = formatValue(parameter,getInputValue(input));
input.setValue(sValue);
// add the input value to the multiple values list
if (sValue.length() > 0) {
values.add(new ContentValue(sValue));
}
}
}
}
示例6: unBind
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Triggered on the save event from the metadata editor.
* <p/>
* On this event, the HtmlInputText input value is propagated to
* the parameter's singleValue.
* @param context the UI context
* @param editorForm the Faces HtmlForm for the metadata editor
* @param parameter the associated parameter
* @throws SchemaException if an associated Faces UIComponent cannot be located
*/
@Override
public void unBind(UiContext context,
UIComponent editorForm,
Parameter parameter)
throws SchemaException {
UIInput input = findInputComponent(context,editorForm);
String sValue = formatValue(parameter,getInputValue(input));
input.setValue(sValue);
parameter.getContent().getSingleValue().setValue(sValue);
}
示例7: clearAllInputs
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* JSF 1.1 provides no way to cleanly discard input fields from a table when
* we know we won't use them. Ideally in such circumstances we'd specify an
* "immediate" action handler (to skip unnecessary validation checks and
* model updates), and then overwrite any existing values. However,
* JSF absolutely insists on keeping any existing input components as
* they are if validation and updating hasn't been done. When the table
* is re-rendered, all of the readonly portions of the columns will be
* refreshed from the backing bean, but the input fields will
* keep their now-incorrect values.
*
* <p>
* The easiest practical way to deal with this limitation is to avoid
* "immediate" actions when a table contains input fields, avoid side-effects
* from the bogus model updates, and stick the user with the inconvenience
* of unnecessary validation errors.
*
* <p>
* The only other solution we've found is to have the backing bean bind to
* the data table component (which just means storing a transient
* pointer to the UIData or HtmlDataTable when it's passed to the
* bean's "setTheDataTable" method), and then to have the action handler call
* this method to walk the table, look for UIInputs on each row, and
* perform the necessary magic on each to force reloading from the data model.
*
* <p>
* Usage:
* <pre>
* private transient HtmlDataTable dataTable;
* public HtmlDataTable getDataTable() {
* return dataTable;
* }
* public void setDataTable(HtmlDataTable dataTable) {
* this.dataTable = dataTable;
* }
* public void processImmediateIdSwitch(ActionEvent event) {
* // ... modify the current ID ...
* FacesUtil.clearAllInputs(dataTable);
* }
* </pre>
*/
public static void clearAllInputs(UIComponent component) {
if (log.isDebugEnabled()) log.debug("clearAllInputs " + component);
if (component instanceof UIInput) {
if (log.isDebugEnabled()) log.debug(" setValid, setValue, setLocalValueSet, setSubmittedValue");
UIInput uiInput = (UIInput)component;
uiInput.setValid(true);
uiInput.setValue(null);
uiInput.setLocalValueSet(false);
uiInput.setSubmittedValue(null);
} else if (component instanceof UIData) {
UIData dataTable = (UIData)component;
int first = dataTable.getFirst();
int rows = dataTable.getRows();
int last;
if (rows == 0) {
last = dataTable.getRowCount();
} else {
last = first + rows;
}
for (int rowIndex = first; rowIndex < last; rowIndex++) {
dataTable.setRowIndex(rowIndex);
if (dataTable.isRowAvailable()) {
for (Iterator iter = dataTable.getChildren().iterator(); iter.hasNext(); ) {
clearAllInputs((UIComponent)iter.next());
}
}
}
} else {
for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
clearAllInputs((UIComponent)iter.next());
}
}
}
示例8: setComponentValue
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* Sets the value for an input component.
* <p/>
* The value set is based upon the supplied parameter's singleValue.
* <p/>
* Default values are evaluated if applicable.
* Date type values are formatted.
* @param context the UI context
* @param input the Faces input component
* @param parameter the associated parameter
*/
public void setComponentValue(UiContext context,
UIInput input,
Parameter parameter) {
String sValue = parameter.getContent().getSingleValue().getValue();
sValue = evaluateDefault(context,sValue);
sValue = formatValue(parameter,sValue);
input.setValue(sValue);
}
示例9: setGenericInput
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* This method is used as generic binding for all input fields of the
* billing contact dialog. The binding was introduced in the context of
* fixing bug #7843. The value of the passed component is will be cleared to
* make sure that the value-binding (happens in a later phase) can set the
* values which are eventually shown in the UI.
*
* @param input
* the UIinput of the webpage.
*/
public void setGenericInput(UIInput input) {
input.setValue(null);
}