本文整理汇总了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());
}
}
}