本文整理匯總了Java中javax.faces.component.UIInput.setSubmittedValue方法的典型用法代碼示例。如果您正苦於以下問題:Java UIInput.setSubmittedValue方法的具體用法?Java UIInput.setSubmittedValue怎麽用?Java UIInput.setSubmittedValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIInput
的用法示例。
在下文中一共展示了UIInput.setSubmittedValue方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: resetInputComponents
import javax.faces.component.UIInput; //導入方法依賴的package包/類
private static void resetInputComponents(UIComponent rootUIComponent) {
if ((rootUIComponent == null) || (rootUIComponent.getChildCount() == 0)) {
return;
}
for (UIComponent comp : rootUIComponent.getChildren()) {
if (comp instanceof UIInput) {
UIInput uiInput = (UIInput) comp;
uiInput.setSubmittedValue(null);
uiInput.setValid(true);
uiInput.setLocalValueSet(false);
uiInput.resetValue();
}
resetInputComponents(comp);
}
}
示例3: decode
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* decode method
* @param context
* @param component
*/
public void decode(FacesContext context, UIComponent component)
{
// we haven't added these attributes--yet--defensive programming...
if(RendererUtil.isDisabledOrReadonly(context, component))
{
return;
}
String clientId = component.getClientId(context);
Map requestParameterMap = context.getExternalContext()
.getRequestParameterMap();
String newValue = (String) requestParameterMap.get(clientId );
UIInput comp = (UIInput) component;
comp.setSubmittedValue(newValue);
}
示例4: decode
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* decode method
* @param context
* @param component
*/
public void decode(FacesContext context, UIComponent component)
{
// we haven't added these attributes--yet--defensive programming...
if(RendererUtil.isDisabledOrReadonly(component))
{
return;
}
String clientId = component.getClientId(context);
Map requestParameterMap = context.getExternalContext()
.getRequestParameterMap();
String newValue = (String) requestParameterMap.get(clientId );
UIInput comp = (UIInput) component;
comp.setSubmittedValue(newValue);
}
示例5: thatEqualPasswordInputsAreCorrect
import javax.faces.component.UIInput; //導入方法依賴的package包/類
@Test
public void thatEqualPasswordInputsAreCorrect(){
when(mockedValue.toString()).thenReturn("password");
UIInput uiInput= new UIInput();
uiInput.setSubmittedValue("password");
Map<String, Object> mapAttributes = new HashMap<>();
mapAttributes.put("confirmPassword", uiInput);
when(mockedUIComponent.getAttributes()).thenReturn(mapAttributes);
when(mockedGuiUtils.getFacesMessage(mockedFacesContext, FacesMessage.SEVERITY_ERROR,
"edit.user.passwordNotEqual")).thenReturn(new FacesMessage("edit.user.passwordNotEqual"));
try {
passwordValidator.validate(mockedFacesContext, mockedUIComponent, mockedValue);
} catch(ValidatorException ex) {
fail("Should not throw a ValidationException");
}
}
示例6: thatNotEqualPasswordInputsThrowsValidationExceptionAndSetInputFieldFalse
import javax.faces.component.UIInput; //導入方法依賴的package包/類
@Test (expected = ValidatorException.class)
public void thatNotEqualPasswordInputsThrowsValidationExceptionAndSetInputFieldFalse() {
when(mockedValue.toString()).thenReturn("password");
UIInput uiInput= new UIInput();
uiInput.setSubmittedValue("password2");
Map<String, Object> mapAttributes = new HashMap<>();
mapAttributes.put("confirmPassword", uiInput);
when(mockedUIComponent.getAttributes()).thenReturn(mapAttributes);
when(mockedGuiUtils.getFacesMessage(mockedFacesContext, FacesMessage.SEVERITY_ERROR,
"edit.user.passwordNotEqual")).thenReturn(new FacesMessage("edit.user.passwordNotEqual"));
passwordValidator.validate(mockedFacesContext, mockedUIComponent, mockedValue);
assertThat("UIInput should be false", uiInput.isValid(), is(false));
}
示例7: resetUIComponent
import javax.faces.component.UIInput; //導入方法依賴的package包/類
/**
* @param component
*/
protected void resetUIComponent(UIComponent component) {
Iterator<UIComponent> childrens = component.getFacetsAndChildren();
if(component instanceof UIInput){
UIInput uiInput = (UIInput) component;
uiInput.setSubmittedValue(null);
}
while(childrens.hasNext()){
resetUIComponent(childrens.next());
}
}
示例8: processActionCancelTemplateSettings
import javax.faces.component.UIInput; //導入方法依賴的package包/類
public String processActionCancelTemplateSettings()
{
log.debug("processActionTemplateSettings()");
// SAK-14073 -- Cleanout values after cancelling.
FacesContext context = FacesContext.getCurrentInstance();
UIInput component = (UIInput) context.getViewRoot().findComponent("revise:moderated");
if (component != null) {
component.setSubmittedValue(null);
}
return processActionHome();
}
示例9: decode
import javax.faces.component.UIInput; //導入方法依賴的package包/類
public void decode(FacesContext context, UIComponent comp)
{
UIInput component = (UIInput) comp;
if (!component.isRendered()) return;
ExternalContext external = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) external.getRequest();
String clientId = component.getClientId(context);
String directory = (String) RendererUtil.getAttribute(context, component, "directory");
// mark that this component has had decode() called during request
// processing
request.setAttribute(clientId + ATTR_REQUEST_DECODED, "true");
// check for user errors and developer errors
boolean atDecodeTime = true;
String errorMessage = checkForErrors(context, component, clientId, atDecodeTime);
if (errorMessage != null)
{
addFacesMessage(context, clientId, errorMessage);
return;
}
// get the file item
FileItem item = getFileItem(context, component);
if (item.getName() == null || item.getName().length() == 0)
{
if (component.isRequired())
{
addFacesMessage(context, clientId, "Please specify a file.");
component.setValid(false);
}
return;
}
if (directory == null || directory.length() == 0)
{
// just passing on the FileItem as the value of the component, without persisting it.
component.setSubmittedValue(item);
}
else
{
// persisting to a permenent file in a directory.
// pass on the server-side filename as the value of the component.
File dir = new File(directory);
String filename = item.getName();
filename = filename.replace('\\','/'); // replaces Windows path seperator character "\" with "/"
filename = filename.substring(filename.lastIndexOf("/")+1);
File persistentFile = new File(dir, filename);
try
{
item.write(persistentFile);
component.setSubmittedValue(persistentFile.getPath());
}
catch (Exception ex)
{
throw new FacesException(ex);
}
}
}
示例10: 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());
}
}
}