?? formcomponent.java
字號:
ValueBinding vb = getValueBinding("styleClass");
if (vb != null) {
return (String) vb.getValue(getFacesContext());
} else {
return styleClass;
}
}
/**
* <p>Set the CSS style class(es) to be rendered for this component.</p>
*
* @param styleClass The new CSS style class(es)
*/
public void setStyleClass(String styleClass) {
this.styleClass = styleClass;
}
/**
* <p>Return the target frame for the response to this form submit.</p>
*/
public String getTarget() {
ValueBinding vb = getValueBinding("target");
if (vb != null) {
return (String) vb.getValue(getFacesContext());
} else {
return target;
}
}
/**
* <p>Set the target frame for the response to this form submit.</p>
*
* @param target The new CSS target(s)
*/
public void setTarget(String target) {
this.target = target;
}
// ---------------------------------------------------------- UIForm Methods
/**
* <p>Create an instance of the form bean (if necessary) before
* delegating to the standard decoding process.</p>
*
* @param context FacesContext for the request we are processing
*/
public void processDecodes(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
if (log.isDebugEnabled()) {
log.debug("processDecodes(" + getClientId(context) + ")");
}
// Create the form bean (if necessary)
Map params = context.getExternalContext().getRequestParameterMap();
if (params.containsKey(getClientId(context))) {
createActionForm(context);
}
// Perform the standard decode processing
super.processDecodes(context);
}
/**
* <p>Restore our state from the specified object.</p>
*
* @param context <code>FacesContext</code> for the current request
* @param state Object containing our saved state
*/
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
action = (String) values[1];
enctype = (String) values[2];
focus = (String) values[3];
focusIndex = (String) values[4];
onreset = (String) values[5];
onsubmit = (String) values[6];
style = (String) values[7];
styleClass = (String) values[8];
target = (String) values[9];
}
/**
* <p>Create and return an object representing our state to be saved.</p>
*
* @param context <code>FacesContext</code> for the current request
*/
public Object saveState(FacesContext context) {
Object values[] = new Object[10];
values[0] = super.saveState(context);
values[1] = action;
values[2] = enctype;
values[3] = focus;
values[4] = focusIndex;
values[5] = onreset;
values[6] = onsubmit;
values[7] = style;
values[8] = styleClass;
values[9] = target;
return (values);
}
// ---------------------------------------------------------- Public Methods
/**
* <p>Create an appropriate form bean in the appropriate scope, if one
* does not already exist.</p>
*
* @param context FacesContext for the current request
*
* @exception IllegalArgumentException if no ActionConfig for the
* specified action attribute can be located
* @exception IllegalArgumentException if no FormBeanConfig for the
* specified form bean can be located
* @exception IllegalArgumentException if no ModuleConfig can be
* located for this application module
*/
public void createActionForm(FacesContext context) {
// Look up the application module configuration information we need
ModuleConfig moduleConfig = lookupModuleConfig(context);
// Look up the ActionConfig we are processing
String action = getAction();
ActionConfig actionConfig = moduleConfig.findActionConfig(action);
if (actionConfig == null) {
throw new IllegalArgumentException("Cannot find action '" +
action + "' configuration");
}
// Does this ActionConfig specify a form bean?
String name = actionConfig.getName();
if (name == null) {
return;
}
// Look up the FormBeanConfig we are processing
FormBeanConfig fbConfig = moduleConfig.findFormBeanConfig(name);
if (fbConfig == null) {
throw new IllegalArgumentException("Cannot find form bean '" +
name + "' configuration");
}
// Does a usable form bean attribute already exist?
String attribute = actionConfig.getAttribute();
String scope = actionConfig.getScope();
ActionForm instance = null;
if ("request".equals(scope)) {
instance = (ActionForm)
context.getExternalContext().getRequestMap().get(attribute);
} else if ("session".equals(scope)) {
HttpSession session = (HttpSession)
context.getExternalContext().getSession(true);
instance = (ActionForm)
context.getExternalContext().getSessionMap().get(attribute);
}
if (instance != null) {
if (fbConfig.getDynamic()) {
String className =
((DynaBean) instance).getDynaClass().getName();
if (className.equals(fbConfig.getName())) {
if (log.isDebugEnabled()) {
log.debug
(" Recycling existing DynaActionForm instance " +
"of type '" + className + "'");
}
return;
}
} else {
try {
Class configClass =
RequestUtils.applicationClass(fbConfig.getType());
if (configClass.isAssignableFrom(instance.getClass())) {
if (log.isDebugEnabled()) {
log.debug
(" Recycling existing ActionForm instance " +
"of class '" + instance.getClass().getName()
+ "'");
}
return;
}
} catch (Throwable t) {
throw new IllegalArgumentException
("Cannot load form bean class '" +
fbConfig.getType() + "'");
}
}
}
// Create a new form bean instance
if (fbConfig.getDynamic()) {
try {
DynaActionFormClass dynaClass =
DynaActionFormClass.createDynaActionFormClass(fbConfig);
instance = (ActionForm) dynaClass.newInstance();
if (log.isDebugEnabled()) {
log.debug
(" Creating new DynaActionForm instance " +
"of type '" + fbConfig.getType() + "'");
log.trace(" --> " + instance);
}
} catch (Throwable t) {
throw new IllegalArgumentException
("Cannot create form bean of type '" +
fbConfig.getType() + "'");
}
} else {
try {
instance = (ActionForm)
RequestUtils.applicationInstance(fbConfig.getType());
if (log.isDebugEnabled()) {
log.debug
(" Creating new ActionForm instance " +
"of type '" + fbConfig.getType() + "'");
log.trace(" --> " + instance);
}
} catch (Throwable t) {
throw new IllegalArgumentException
("Cannot create form bean of class '" +
fbConfig.getType() + "'");
}
}
// Configure and cache the form bean instance in the correct scope
ActionServlet servlet = (ActionServlet)
context.getExternalContext().getApplicationMap().get
(Globals.ACTION_SERVLET_KEY);
instance.setServlet(servlet);
if ("request".equals(scope)) {
context.getExternalContext().getRequestMap().put
(attribute, instance);
} else if ("session".equals(scope)) {
context.getExternalContext().getSessionMap().put
(attribute, instance);
}
}
/**
* <p>Return the <code>ModuleConfig</code> for the application module
* this form is being processed for.</p>
*
* @param context The <code>FacesContext</code> for the current request
*
* @exception IllegalArgumentException if no <code>ModuleConfig</code>
* can be found
*/
public ModuleConfig lookupModuleConfig(FacesContext context) {
// Look up the application module configuration information we need
ModuleConfig modConfig = (ModuleConfig)
context.getExternalContext().getRequestMap().get
(Globals.MODULE_KEY);
if (modConfig == null) {
modConfig = (ModuleConfig)
context.getExternalContext().getApplicationMap().get
(Globals.MODULE_KEY);
}
if (modConfig == null) {
throw new IllegalArgumentException
("Cannot find module configuration");
}
return (modConfig);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -