本文整理汇总了Java中javax.faces.application.Application类的典型用法代码示例。如果您正苦于以下问题:Java Application类的具体用法?Java Application怎么用?Java Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于javax.faces.application包,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _evaluateValueExpressions
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Cut-and-paste reuse from org/apache/myfaces/context/servlet/ServletExternalContextImpl.
*
* Checks the Strings in the List for EL expressions and evaluates them.
* Note that the returned List will be a copy of the given List, because
* otherwise it will have unwanted side-effects.
* @param context faces context
* @param values from a query parameter that might have EL
* @return resultant list will have any embedded EL evaluated
*/
private List<String> _evaluateValueExpressions(FacesContext context, List<String> values)
{
// note that we have to create a new List here, because if we
// change any value on the given List, it will be changed in the
// NavigationCase too and the EL expression won't be evaluated again
List<String> target = new ArrayList<String>(values.size());
for (String value: values)
{
if (_isExpression(value))
{
if (context == null)
throw new UnsupportedOperationException("FacesContext not established yet. Unable to resolve EL bound query" +
"parameter value: \"" + value + "\"");
Application app = context.getApplication();
String dynamicValue = app.evaluateExpressionGet(context, value, String.class);
target.add(dynamicValue);
}
else
target.add(value);
}
return target;
}
示例2: handleError
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Handle a server-side error by reporting it back to the client.
*/
public static void handleError(ExternalContext ec,
Throwable t) throws IOException
{
String error = _getErrorString();
_LOG.severe(error, t);
ServletResponse response = (ServletResponse)ec.getResponse();
PrintWriter writer = response.getWriter();
XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
rw.startDocument();
rw.startElement("partial-response", null);
rw.startElement("error", null);
rw.startElement("error-name", null);
rw.writeText(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
rw.endElement("error-name");
String errorMessage = _getErrorMessage(error);
// Default exception message contains the type of the exception.
// Do not send this info to client in Production mode
ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
if (application.getProjectStage() != ProjectStage.Production)
{
errorMessage = _getExceptionString(t) + errorMessage;
}
rw.startElement("error-message", null);
rw.writeText(errorMessage, null);
rw.endElement("error-message");
rw.endElement("error");
rw.endElement("partial-response");
rw.endDocument();
rw.close();
}
示例3: _createValueExpressionFromApplication
import javax.faces.application.Application; //导入依赖的package包/类
private static ValueExpression _createValueExpressionFromApplication(
String expression,
Class<?> expectedType)
{
ApplicationFactory factory = (ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
if (factory != null)
{
Application application = factory.getApplication();
if (application != null)
{
ELContext elContext = _getELContext(application);
ExpressionFactory expressionFactory = application.getExpressionFactory();
if (expressionFactory != null)
{
return expressionFactory.createValueExpression(elContext, expression, expectedType);
}
}
}
return null;
}
示例4: _executeValidate
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Executes validation logic.
*/
private void _executeValidate(FacesContext context)
{
Application application = context.getApplication();
application.publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
try
{
validate(context);
}
catch (RuntimeException e)
{
context.renderResponse();
throw e;
}
finally
{
application.publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
}
if (!isValid())
{
context.renderResponse();
}
}
示例5: LightWidget
import javax.faces.application.Application; //导入依赖的package包/类
public LightWidget(Long id, LightSensorVO sensor, Application application, IndexManager manager) {
this.id = id;
this.type = "Sensor";
this.lightSensor = sensor;
this.application = application;
this.manager = manager;
gaugeModel = new MeterGaugeChartModel(null, intervals);
gaugeModel.setSeriesColors("00396B,81e741,f2ee00");
gaugeModel.setGaugeLabelPosition("bottom");
gaugeModel.setShowTickLabels(true);
gaugeModel.setLabelHeightAdjust(0);
gaugeModel.setMin(0);
gaugeModel.setMax(1000);
gaugeModel.setTitle(lightSensor.getName());
gaugeModel.setValue(lightSensor.getData().getData());
gaugeModel.setGaugeLabel(lightSensor.getData().toString());
}
示例6: TemperatureWidget
import javax.faces.application.Application; //导入依赖的package包/类
public TemperatureWidget(Long id, TemperatureSensorVO tempSensor, Application application, IndexManager manager) {
this.id = id;
this.type = "Sensor";
this.tempSensor = tempSensor;
this.application = application;
this.manager = manager;
gaugeModel = new MeterGaugeChartModel(null, intervals);
gaugeModel.setSeriesColors("2c7bf6,97dafb,88c82a,edec5b,c43030");
gaugeModel.setGaugeLabelPosition("bottom");
gaugeModel.setShowTickLabels(true);
gaugeModel.setLabelHeightAdjust(0);
gaugeModel.setMin(-10);
gaugeModel.setMax(60);
gaugeModel.setTitle(tempSensor.getName());
gaugeModel.setValue(tempSensor.getData().getData());
gaugeModel.setGaugeLabel(tempSensor.getData().toString());
}
示例7: logout
import javax.faces.application.Application; //导入依赖的package包/类
public void logout() {
FacesContext fc = javax.faces.context.FacesContext.getCurrentInstance();
((HttpSession) fc.getExternalContext().getSession(false)).invalidate();
// FacesContext.getCurrentInstance().getExternalContext().getSessionMap().clear();
Application ap = fc.getApplication();
NavigationHandler nh = ap.getNavigationHandler();
//Generate Logout Dialog
List<String> buttonTextList = new ArrayList<String>();
buttonTextList.add(resolve("Login", new Object[]{}));
NotifyDescriptorExt n = new NotifyDescriptorExt(Constants.INFORMATION_ICON, resolve("Logouted", new Object[]{}), resolve("LogoutMessage", new Object[]{}), buttonTextList);
String page = n.setCallbackListener(new ButtonListener() {
public String buttonClicked(final int buttonId, NotifyDescriptorExtBean notifyDescriptorBean) {
return NavigationEnum.controller_CenterPanel.toString();
}
});
//Load the NotifyDescriptor because after logout the JSF logic is expired.
nh.handleNavigation(fc, null, page);
}
示例8: getJSFInfo
import javax.faces.application.Application; //导入依赖的package包/类
/**
* gets JSF information like JSF version and Faces context.
*
* @return the JSF info
*/
public static Map<String, Object> getJSFInfo() {
final LinkedHashMap<String, Object> details = new LinkedHashMap<String, Object>();
final FacesContext context = FacesContext.getCurrentInstance();
final Application application = context.getApplication();
final ViewHandler viewHandler = application.getViewHandler();
final ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, context.getViewRoot().getViewId());
final LifecycleFactory LifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
details.put("JSF-Version", FacesContext.class.getPackage().getImplementationVersion());
details.put("JSF-Version-Package", FacesContext.class.getPackage().getName());
details.put("FacesContext", context.getClass());
details.put("Application", application.getClass());
details.put("ViewHandler", viewHandler.getClass());
details.put("ViewDeclarationLanguage", vdl.getClass());
details.put("LifecycleFactory", LifecycleFactory.getClass());
return details;
}
示例9: debug
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Output RAS message.
* @param msg Message to be output.
*/
static final public void debug(String msg) {
FacesContext context = FacesContext.getCurrentInstance();
if (context != null) {
Application app = context.getApplication();
if (app != null) {
ProjectStage stage = app.getProjectStage();
if (stage == ProjectStage.Development || stage == ProjectStage.UnitTest) {
setDebug(true);
}
}
if (debug) {
System.out.println(msg);
}
}
}
示例10: goToRightPage
import javax.faces.application.Application; //导入依赖的package包/类
public void goToRightPage() {
String viewId = this.originalViewId;
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
ViewHandler viewHandler = app.getViewHandler();
UIViewRoot root = viewHandler.createView(context, viewId);
context.setViewRoot(root);
if ("/datacenter/dataCenterSimulationRealTime.xhtml".equals(viewId)) {
this.dataCenterControllerSimulator.initHostMachineSimulatorList();
}
if ("/datacenter/dataCenterVirtualMachinePlacement.xhtml".equals(viewId)) {
this.dataCenterController.getDataCenterVirtualMachinePlacementSimulator().setDataCenter(dataCenterController.getDataCenter());
}
if ("/datacenter/vmPlacementTestRunner.xhtml".equals(viewId)) {
this.dataCenterController.getPlacementSimulatorTestRunner().setDataCenter(dataCenterController.getDataCenter());
}
}
示例11: setAction
import javax.faces.application.Application; //导入依赖的package包/类
public static void setAction(UIComponent component,
String attributeValue)
{
if (attributeValue == null)
{
return;
}
if (UIComponentTag.isValueReference(attributeValue))
{
setMethodBinding(component, "action", attributeValue,
new Class[]
{});
}
else
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = new ActionMethodBinding(attributeValue);
component.getAttributes().put("action", mb);
}
}
示例12: setMethodBinding
import javax.faces.application.Application; //导入依赖的package包/类
public static void setMethodBinding(UIComponent component,
String attributeName,
String attributeValue, Class[] paramTypes)
{
if (attributeValue == null)
{
return;
}
if (UIComponentTag.isValueReference(attributeValue))
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = app.createMethodBinding(attributeValue,
paramTypes);
component.getAttributes().put(attributeName, mb);
}
}
示例13: eval
import javax.faces.application.Application; //导入依赖的package包/类
public static String eval(String expression)
{
if (expression == null)
{
return null;
}
if (UIComponentTag.isValueReference(expression))
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
return "" + app.createValueBinding(expression).getValue(context);
}
else
{
return expression;
}
}
示例14: setAction
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Set an action on a component - used by tags setProperties() method.
* Handles method bindings.
*/
public static void setAction(UIComponent component, String value)
{
if (value == null)
{
return;
}
if (UIComponentTag.isValueReference(value))
{
setMethodBinding(component, "action", value, new Class[] {});
} else
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = new ActionMethodBinding(value);
component.getAttributes().put("action", mb);
}
}
示例15: setMethodBinding
import javax.faces.application.Application; //导入依赖的package包/类
/**
* Set a MethodBinding on a component - used by tags setProperties() method.
*/
public static void setMethodBinding(UIComponent component, String name, String value,
Class[] paramTypes)
{
if (value == null)
{
return;
}
if (UIComponentTag.isValueReference(value))
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = app.createMethodBinding(value, paramTypes);
component.getAttributes().put(name, mb);
}
}