本文整理汇总了Java中javax.faces.event.SystemEvent类的典型用法代码示例。如果您正苦于以下问题:Java SystemEvent类的具体用法?Java SystemEvent怎么用?Java SystemEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SystemEvent类属于javax.faces.event包,在下文中一共展示了SystemEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createActionEventListener
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* viewIdに対応付けられているActionListener実装クラスインスタンスを生成する.
* <p>
* 設定ファイル(system-event-listener.properties)で、イベント名とviewId(画面ID)
* を組み合わせた内容が設定キーです。
* <p>
* 例)prerender.admin.adminHome=jp.co.opentone.bsol.mer.view.admin.AdminHomePrerenderListener
* <p>
* 引数prefixには上例の"prerender"に該当する文字列を指定します.
* @param event {@link SystemEvent}
* @param prefix 設定prefix
* @return 生成したActionListenerインスタンス. 設定無しの場合はnull
* @throws AbortProcessingException {@link AbortProcessingException}
*/
protected ExtendedActionListener createActionEventListener(SystemEvent event, String prefix)
throws AbortProcessingException {
ExtendedActionListener listener = null;
Object source = event.getSource();
if (source instanceof UIViewRoot) {
UIViewRoot viewRoot = (UIViewRoot) source;
String viewId = viewRoot.getViewId();
if (StringUtils.isNotEmpty(viewId)) {
// viewIdをプロパティキーに変換
String propKey = PropertyUtil.createPropertyKeyForViewId(prefix, viewId);
listener = createActionEventListener(propKey);
}
}
return listener;
}
示例2: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreValidateEvent) {
UIViewRoot viewRoot = getUIViewRoot(event);
if (null != viewRoot) {
ActionListener listener
= createActionEventListener(event, PROP_VALIDATOR_PREFIX);
if (null != listener) {
// PreValidaeEventは必要な場合だけ登録されるので、存在しない場合でも
// エラーではありません.
ActionEvent ae = new ActionEvent(viewRoot);
listener.processAction(ae);
}
}
}
}
示例3: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* We get PreDestroyViewMapEvent events from the JSF servlet and destroy our
* contextual instances. This should (theoretically!) also get fired if the
* webapp closes, so there should be no need to manually track all view
* scopes and destroy them at a shutdown.
*
* @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
*/
@SuppressWarnings("unchecked")
@Override
public void processEvent(final SystemEvent event) {
if (event instanceof PreDestroyViewMapEvent) {
Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalInstanceMap();
if (componentInstanceMap != null) {
for (Map.Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet()) {
/*
* No way to inform the compiler of type <T> information, so
* it has to be abandoned here :(
*/
Contextual contextual = componentEntry.getKey();
Object instance = componentEntry.getValue();
CreationalContext creational = creationalContextMap.get(contextual);
contextual.destroy(instance, creational);
}
}
}
}
示例4: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PostAddToViewEvent) {
for (UIComponent child : getChildren()) {
// Add form-label class to span children
if (child instanceof HtmlOutputLabel) {
HtmlOutputLabel label = (HtmlOutputLabel) child;
label.setStyleClass(StyleClass.of("form-label").add(label.getStyleClass()).toString());
}
// Add label from form-element to inputs with no label and vise-versa
else if (child instanceof UIInput) {
String elemLabel = getLabel();
String inputLabel = (String) child.getAttributes().get("label");
if (elemLabel != null && inputLabel == null)
child.getAttributes().put("label", elemLabel);
else if (elemLabel == null && inputLabel != null)
setLabel(inputLabel);
}
}
}
}
示例5: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* We get PreDestroyViewMapEvent events from the JSF servlet and destroy our
* contextual instances. This should (theoretically!) also get fired if the
* webapp closes, so there should be no need to manually track all view
* scopes and destroy them at a shutdown.
*
* @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
*/
@Override
public void processEvent(final SystemEvent event) {
if (event instanceof PreDestroyViewMapEvent) {
Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalInstanceMap();
if (componentInstanceMap != null) {
for (Map.Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet()) {
/*
* No way to inform the compiler of type <T> information, so
* it has to be abandoned here :(
*/
Contextual contextual = componentEntry.getKey();
Object instance = componentEntry.getValue();
CreationalContext creational = creationalContextMap.get(contextual);
contextual.destroy(instance, creational);
}
}
}
}
示例6: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException
{
/** UIViewRoot root = (UIViewRoot) event.getSource();
FacesContext ctx = FacesContext.getCurrentInstance();
String path = ctx.getExternalContext().getRequestContextPath();
ResponseWriter writer = ctx.getResponseWriter();
try
{
writer = new CsapiHtmlResponseWriterImpl(((ServletResponse) ctx.getExternalContext().getResponse()).getWriter(), null, null);
}
catch (IOException ex)
{
ex.printStackTrace();
}
ctx.setResponseWriter(writer);
**/
}
示例7: publishEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void publishEvent(FacesContext context,
Class<? extends SystemEvent> systemEventClass,
Class<?> sourceBaseType,
Object source)
{
// do nothing
}
示例8: subscribeToEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass,
Class<?> sourceClass,
SystemEventListener listener)
{
// make unit tests happy
}
示例9: unsubscribeFromEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass,
Class<?> sourceClass,
SystemEventListener listener)
{
// make unit tests happy
}
示例10: subscribeToEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void subscribeToEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener)
{
if (eventClass == null)
{
throw new NullPointerException("eventClass required");
}
if (componentListener == null)
{
throw new NullPointerException("componentListener required");
}
FacesBean bean = getFacesBean();
AttachedObjects<Class<? extends SystemEvent>, SystemEventListener> eventStorage =
(AttachedObjects<Class<? extends SystemEvent>, SystemEventListener>)bean.getProperty(_SYSTEM_EVENT_LISTENERS_KEY);
if (eventStorage == null)
{
eventStorage = new AttachedObjects<Class<? extends SystemEvent>, SystemEventListener>();
bean.setProperty(_SYSTEM_EVENT_LISTENERS_KEY, eventStorage);
}
if (componentListener instanceof SystemEventListener && componentListener instanceof StateHolder)
eventStorage.addAttachedObject(eventClass, (SystemEventListener) componentListener);
else
eventStorage.addAttachedObject(eventClass, new ComponentSystemEventListenerWrapper(componentListener, this));
}
示例11: unsubscribeFromEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass,
ComponentSystemEventListener componentListener)
{
if (eventClass == null)
{
throw new NullPointerException("eventClass required");
}
if (componentListener == null)
{
throw new NullPointerException("componentListener required");
}
FacesBean bean = getFacesBean();
AttachedObjects<Class<? extends SystemEvent>, SystemEventListener> eventStorage =
(AttachedObjects<Class<? extends SystemEvent>, SystemEventListener>)bean.getProperty(_SYSTEM_EVENT_LISTENERS_KEY);
if (eventStorage == null)
{
return;
}
if (componentListener instanceof SystemEventListener && componentListener instanceof StateHolder)
{
eventStorage.removeAttachedObject(eventClass, (SystemEventListener) componentListener);
}
else
{
// ComponentSystemEventListenerWrapper implements equals() to compare listener and component
eventStorage.removeAttachedObject(eventClass, new ComponentSystemEventListenerWrapper(componentListener, this));
}
}
示例12: getListenersForEventClass
import javax.faces.event.SystemEvent; //导入依赖的package包/类
@Override
public List<SystemEventListener> getListenersForEventClass(Class<? extends SystemEvent> eventClass)
{
FacesBean bean = getFacesBean();
AttachedObjects<Class<? extends SystemEvent>, SystemEventListener> eventStorage =
(AttachedObjects<Class<? extends SystemEvent>, SystemEventListener>)bean.getProperty(_SYSTEM_EVENT_LISTENERS_KEY);
if (eventStorage == null)
{
return Collections.emptyList();
}
return eventStorage.getAttachedObjectList(eventClass);
}
示例13: processEvent
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* システムイベントの発生元の{@code UIInput}でバリデーションエラーが発生していた場合、入力項目の{@code styleClass}
* 属性に {@code inputError}を追加します。 バリデーションエラーが発生していなかった場合、入力項目の
* {@code styleClass}属性から{@code inputError}を除去します。
*/
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
UIInput input = (UIInput) event.getSource();
if (input.isValid()) {
removeErrorStyleClass(input.getAttributes());
} else {
addErrorStyleClass(input.getAttributes());
}
}
示例14: getUIViewRoot
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* SystemEventのソースがUIViewRootの場合はUIViewRootを返します.
* @param event {@link SystemEvent}
* @return ソースがUIViewRootの場合はUIViewRoot. そうでない場合はnull.
*/
protected UIViewRoot getUIViewRoot(SystemEvent event) {
UIViewRoot viewRoot = null;
Object source = event.getSource();
if (source instanceof UIViewRoot) {
viewRoot = (UIViewRoot) source;
}
return viewRoot;
}
示例15: getViewId
import javax.faces.event.SystemEvent; //导入依赖的package包/类
/**
* SystemEventのソースがUIViewRootの場合はviewIdを返します.
* @param event {@link SystemEvent}
* @return ソースがUIViewRootの場合はviewId. そうでない場合はnull.
*/
protected String getViewId(SystemEvent event) {
String viewId = null;
UIViewRoot viewRoot = getUIViewRoot(event);
if (null != viewRoot) {
viewId = viewRoot.getViewId();
}
return viewId;
}