本文整理匯總了Java中javax.faces.event.PhaseEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PhaseEvent類的具體用法?Java PhaseEvent怎麽用?Java PhaseEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PhaseEvent類屬於javax.faces.event包,在下文中一共展示了PhaseEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getListener
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public PhaseListener getListener() {
return new PhaseListener() {
private static final long serialVersionUID = -66585096775189540L;
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
public void beforePhase(PhaseEvent event) {
unselectCategory();
}
public void afterPhase(PhaseEvent arg0) {
// nothing
}
};
}
示例2: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
@Override
public void beforePhase(PhaseEvent phaseEvent) {
FacesContext facesContext = phaseEvent.getFacesContext();
HttpServletResponse response = (HttpServletResponse) facesContext
.getExternalContext().getResponse();
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache,no-store,must-revalidate");
response.addHeader("Expires", "0");
}
示例3: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void beforePhase(PhaseEvent phaseEvent)
{
// Add event code here...
System.out.println("***PhaseTracker: After Phase: " + phaseEvent.getPhaseId());
RenderingContext rContext = RenderingContext.getCurrentInstance();
if (rContext != null)
{
System.out.println("Set Skin to dirty if button was pressed, and it is set to :" + _pressedButton);
if (_pressedButton)
{
System.out.println("Setting the skin to be dirty will allow you to refresh your browser and see any changes to the skin's css file immediately.");
rContext.getSkin().setDirty(true);
_pressedButton = false;
}
else
{
System.out.println("Set Skin to not be dirty");
rContext.getSkin().setDirty(false);
}
}
else
System.out.println("rContext in _afterPhase is null!");
}
示例4: beforeAndAfterPhaseWithMultipleTargets
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
@Test
public void beforeAndAfterPhaseWithMultipleTargets() {
TestListener target1 = new TestListener();
TestListener target2 = new TestListener();
beanFactory.addBean("testListener1", target1);
beanFactory.addBean("testListener2", target2);
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE);
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event);
assertTrue(target1.beforeCalled);
assertTrue(target2.beforeCalled);
delPhaseListener.afterPhase(event);
assertTrue(target1.afterCalled);
assertTrue(target2.afterCalled);
}
示例5: afterPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
@Override
public void afterPhase(PhaseEvent event) {
if (!getPhaseId().equals(event.getPhaseId())) {
return;
}
// いずれかのコンポーネントにメッセージが設定されている場合は
// 入力エラーがあることを表すメッセージを追加する
if (FacesContext.getCurrentInstance().getClientIdsWithMessages().hasNext()) {
Message m = Messages.getMessage(MessageCode.E_INVALID_INPUT);
FacesMessage fm = new FacesMessage(
FacesMessage.SEVERITY_ERROR,
m.getSummary(),
m.getMessage());
FacesContext.getCurrentInstance().addMessage(null, fm);
}
}
示例6: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
@Override
public void beforePhase(PhaseEvent event) {
HttpServletRequest req =
(HttpServletRequest) FacesContext.getCurrentInstance()
.getExternalContext().getRequest();
log.info("Requested: {} {}", req.getMethod(), req.getRequestURI());
Enumeration<?> enm = req.getHeaderNames();
log.info("Header:");
while (enm.hasMoreElements()) {
String name = (String) enm.nextElement();
log.info(" {} = {}", name, req.getHeader(name));
}
log.info(" Parameters:");
@SuppressWarnings("unchecked")
Map<String, String[]> parameterMap = req.getParameterMap();
for (Map.Entry<String, String[]> e : parameterMap.entrySet()) {
log.info(" {} = {}", e.getKey(), StringUtils.join(e.getValue()));
}
}
示例7: reportPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
private void reportPhase (PhaseEvent event, boolean after) {
HttpSession session = (HttpSession) event.getFacesContext().getExternalContext().getSession(false);
if (session != null) {
if (after && event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
session.removeAttribute(PHASE);
} else {
if (!after) session.setAttribute(PHASE, event.getPhaseId());
}
}
if (!after && event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
//DumpView(event.getFacesContext());
}
//System.out.println ("**********************"+(after ? "AFTER " : "BEFORE ")+event.getPhaseId()+" session="+session); System.out.flush();
}
示例8: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void beforePhase( @Observes @Before PhaseEvent e )
{
View view = new View( conversation.getId() );
if ( view.isSeamPage() && !isOnTop( view ) )
{
if ( isSecondLast( view ) )
{
popUntilView( view );
View top = getTopView();
if ( top != null )
{
top.setMarked( false );
top.setSelection( null );
}
log.debug("BACK TO [" + view.getConversationId() + "]: " + view );
}
else
{
views.push( view );
log.debug( "NEXT TO [" + view.getConversationId() + "]: " + view );
}
}
}
示例9: afterPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void afterPhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
String currentPage = facesContext.getViewRoot().getViewId();
boolean isLoginPage = (currentPage.lastIndexOf("login.jsp") > -1);
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
String user = (String)session.getAttribute("userName");
if (!isLoginPage && user == null) {
NavigationHandler nh = facesContext.getApplication()
.getNavigationHandler();
nh.handleNavigation(facesContext, null, "loginPage");
}
}
示例10: afterPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void afterPhase(PhaseEvent event) {
PhaseId curId = event.getPhaseId();
if (PhaseId.APPLY_REQUEST_VALUES.equals(curId)) {
doAfterApplyRequest(event);
} else if (PhaseId.INVOKE_APPLICATION.equals(curId)) {
doAfterInvokeApplication(event);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(curId)) {
doAfterProcessValidations(event);
} else if (PhaseId.RENDER_RESPONSE.equals(curId)) {
doAfterRenderResponse(event);
} else if (PhaseId.RESTORE_VIEW.equals(curId)) {
doAfterRestoreView(event);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(curId)) {
doAfterUpdateModel(event);
}
doAfterEveryPhase(event);
}
示例11: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void beforePhase(PhaseEvent event) {
PhaseId curId = event.getPhaseId();
if (PhaseId.APPLY_REQUEST_VALUES.equals(curId)) {
doBeforeApplyRequest(event);
} else if (PhaseId.INVOKE_APPLICATION.equals(curId)) {
doBeforeInvokeApplication(event);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(curId)) {
doBeforeProcessValidations(event);
} else if (PhaseId.RENDER_RESPONSE.equals(curId)) {
doBeforeRenderResponse(event);
} else if (PhaseId.RESTORE_VIEW.equals(curId)) {
doBeforeRestoreView(event);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(curId)) {
doBeforeUpdateModel(event);
}
doBeforeEveryPhase(event);
}
示例12: testBeforeAndAfterPhaseWithMultipleTargets
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void testBeforeAndAfterPhaseWithMultipleTargets() {
TestListener target1 = new TestListener();
TestListener target2 = new TestListener();
beanFactory.addBean("testListener1", target1);
beanFactory.addBean("testListener2", target2);
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE);
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event);
assertTrue(target1.beforeCalled);
assertTrue(target2.beforeCalled);
delPhaseListener.afterPhase(event);
assertTrue(target1.afterCalled);
assertTrue(target2.afterCalled);
}
示例13: afterPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
/**
* Faces event fired after a PhaseEvent is processed.
*/
public void afterPhase(PhaseEvent event) {
if (event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
onExecutionPhaseCompleted();
}
LogUtil.getLogger().finest("After phase: "+event.getPhaseId().toString());
if(LogUtil.getLogger().isLoggable(Level.FINEST) &&
event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)){
//LogUtil.getLogger().finest("Printing the tree");
//DebugUtil.printTree(
// FacesContext.getCurrentInstance().getViewRoot(),System.out);
}
}
示例14: afterPhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void afterPhase(PhaseEvent arg0) {
PhaseId curId = arg0.getPhaseId();
if (PhaseId.APPLY_REQUEST_VALUES.equals(curId)) {
doAfterApplyRequest(arg0);
} else if (PhaseId.INVOKE_APPLICATION.equals(curId)) {
doAfterInvokeApplication(arg0);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(curId)) {
doAfterProcessValidations(arg0);
} else if (PhaseId.RENDER_RESPONSE.equals(curId)) {
doAfterRenderResponse(arg0);
} else if (PhaseId.RESTORE_VIEW.equals(curId)) {
doAfterRestoreView(arg0);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(curId)) {
doAfterUpdateModel(arg0);
}
doAfterEveryPhase(arg0);
}
示例15: beforePhase
import javax.faces.event.PhaseEvent; //導入依賴的package包/類
public void beforePhase(PhaseEvent arg0) {
PhaseId curId = arg0.getPhaseId();
if (PhaseId.APPLY_REQUEST_VALUES.equals(curId)) {
doBeforeApplyRequest(arg0);
} else if (PhaseId.INVOKE_APPLICATION.equals(curId)) {
doBeforeInvokeApplication(arg0);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(curId)) {
doBeforeProcessValidations(arg0);
} else if (PhaseId.RENDER_RESPONSE.equals(curId)) {
doBeforeRenderResponse(arg0);
} else if (PhaseId.RESTORE_VIEW.equals(curId)) {
doBeforeRestoreView(arg0);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(curId)) {
doBeforeUpdateModel(arg0);
}
doBeforeEveryPhase(arg0);
}