Java Code Examples for javax.faces.event.PhaseId

The following are top voted examples for showing how to use javax.faces.event.PhaseId. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm   File: CategorySelectionBean.java   Source Code and License 7 votes vote down vote up
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
        }
    };
}
 
Example 2
Project: sakai   File: EventPager.java   Source Code and License 7 votes vote down vote up
public void handleValueChange (ValueChangeEvent event)
{
    PhaseId
        phaseId = event.getPhaseId();

    String
        oldValue = (String) event.getOldValue(),
        newValue = (String) event.getNewValue();

    if (phaseId.equals(PhaseId.ANY_PHASE))
    {
        event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
        event.queue();
    }
    else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
    {
    // do you method here
    }
}
 
Example 3
Project: myfaces-trinidad   File: PartialViewContextImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void processPartial(PhaseId phaseId)
{
  UIViewRoot viewRoot = _context.getViewRoot();
  if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
      phaseId == PhaseId.PROCESS_VALIDATIONS ||
      phaseId == PhaseId.UPDATE_MODEL_VALUES)
  {
    _processExecute(viewRoot, phaseId);
  }
  else if (phaseId == PhaseId.RENDER_RESPONSE)
  {
    _processRender(viewRoot);
  }

}
 
Example 4
Project: myfaces-trinidad   File: PartialViewContextImpl.java   Source Code and License 6 votes vote down vote up
private void _processExecute(UIViewRoot component, PhaseId phaseId)
{
  // We are only handling visit-based (partial) execution here.
  // Full execution (isExecuteAll() == true) is handled by the UIViewRoot
  // Note that this is different from the render phase

  Collection<String> executeIds = getExecuteIds();
  if (executeIds == null || executeIds.isEmpty())
  {
    _LOG.warning("No execute Ids were supplied for the Ajax request");
    return;
  }

  VisitContext visitContext = VisitContext.createVisitContext(_context, executeIds,
                      EnumSet.of(VisitHint.SKIP_UNRENDERED, VisitHint.EXECUTE_LIFECYCLE));
  VisitCallback visitCallback = new ProcessPhaseCallback(_context, phaseId);

  component.visitTree(visitContext, visitCallback);
}
 
Example 5
Project: myfaces-trinidad   File: PartialViewContextImpl.java   Source Code and License 6 votes vote down vote up
public VisitResult visit(VisitContext context, UIComponent target)
{
  if (_phaseId == PhaseId.APPLY_REQUEST_VALUES)
  {
    target.processDecodes(_context);
  }
  else if (_phaseId == PhaseId.PROCESS_VALIDATIONS)
  {
    target.processValidators(_context);
  }
  else if (_phaseId == PhaseId.UPDATE_MODEL_VALUES)
  {
    target.processUpdates(_context);
  }


  // No need to visit children, since they will be executed/rendred by their parents
  return VisitResult.REJECT;
}
 
Example 6
Project: myfaces-trinidad   File: RenderKitTestCase.java   Source Code and License 6 votes vote down vote up
@Override
protected void setUp() throws IOException
{
  _facesContext = createMockFacesContext(MApplication.sharedInstance(), true);
  _requestContext = createRequestContext();
  _requestContext.setSkinFamily(_skinFamily);
  _requestContext.setAgent(_agent);
  _requestContext.setRightToLeft(_rightToLeft);
  _requestContext.setOutputMode(_outputMode);
  _requestContext.setAccessibilityMode(_accMode);
  _facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE);

  UIViewRoot root = RenderKitBootstrap.createUIViewRoot(_facesContext);
  root.setRenderKitId(getRenderKitId());
  _facesContext.setViewRoot(root);

  ExtendedRenderKitService service =
    _getExtendedRenderKitService(_facesContext);

  if (service != null)
    service.encodeBegin(_facesContext);
}
 
Example 7
Project: myfaces-trinidad   File: TableUtils.java   Source Code and License 6 votes vote down vote up
/**
 * This method sets the phaseID of the event
 * according to the "immediate" property of this
 * component.
 * If "immediate" is set to true, this calls
 * {@link FacesContext#renderResponse}
 */
static void __handleQueueEvent(UIComponent comp, FacesEvent event)
{
  if (_isImmediateEvent(comp, event))
  {
    String immediateAttr = UIXTree.IMMEDIATE_KEY.getName();
    Object isImmediate = comp.getAttributes().get(immediateAttr);
    if (Boolean.TRUE.equals(isImmediate))
    {
      event.setPhaseId(PhaseId.ANY_PHASE);
      FacesContext context = FacesContext.getCurrentInstance();
      context.renderResponse();
    }
    else
    {
      // the event should not execute before model updates are done. 
      // otherwise, the updates will be done to the wrong rows.

      // we can't do this at the end of the UPDATE_MODEL phase because
      // if there are errors during that phase, then we want to immediately render
      // the response, and not deliver this ui event:
      event.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }
}
 
Example 8
Project: myfaces-trinidad   File: TableUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Process all the children of the given table
 */
@SuppressWarnings("unchecked")
static void __processChildren(
  FacesContext context,
  final UIXCollection comp,
  final PhaseId phaseId)
{

  // process the children
  int childCount = comp.getChildCount();
  if (childCount != 0)
  {
    List<UIComponent> children = comp.getChildren();

    for (int i = 0; i < childCount; i++)
    {
      UIComponent child = children.get(i);
      comp.processComponent(context, child, phaseId);
    }
  }          
}
 
Example 9
Project: myfaces-trinidad   File: UIXCollection.java   Source Code and License 6 votes vote down vote up
/**
 * Process a component.
 * This method calls {@link #processDecodes(FacesContext)},
 * {@link #processValidators} or
 * {@link #processUpdates}
 * depending on the {#link PhaseId}.
 */
protected final void processComponent(
  FacesContext context,
  UIComponent  component,
  PhaseId      phaseId)
{
  if (component != null)
  {
    if (phaseId == PhaseId.APPLY_REQUEST_VALUES)
      component.processDecodes(context);
    else if (phaseId == PhaseId.PROCESS_VALIDATIONS)
      component.processValidators(context);
    else if (phaseId == PhaseId.UPDATE_MODEL_VALUES)
      component.processUpdates(context);
    else
      throw new IllegalArgumentException(_LOG.getMessage(
        "BAD_PHASEID",phaseId));
  }
}
 
Example 10
Project: myfaces-trinidad   File: UIXTableTemplate.java   Source Code and License 6 votes vote down vote up
@Override
protected void processFacetsAndChildren(
  FacesContext context,
  PhaseId phaseId)
{
  // process all the facets of this table just once
  // (except for the "detailStamp" facet which must be processed once
  // per row):
  TableUtils.processFacets(context, this, this, phaseId,
    UIXTable.DETAIL_STAMP_FACET);

  // process all the facets of this table's column children:
  TableUtils.processColumnFacets(context, this, this, phaseId);

  // process all the children and the detailStamp as many times as necessary
  processStamps(context, phaseId);
}
 
Example 11
Project: myfaces-trinidad   File: UIXPollTemplate.java   Source Code and License 6 votes vote down vote up
@Override
public void queueEvent(FacesEvent e)
{
  if ((e instanceof PollEvent) && (e.getSource() == this))
  {
    if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }

  super.queueEvent(e);
}
 
Example 12
Project: myfaces-trinidad   File: UIXProcessTemplate.java   Source Code and License 6 votes vote down vote up
@Override
protected void processFacetsAndChildren(
  FacesContext context,
  PhaseId phaseId)
{
  Object oldPath = getRowKey();
  try
  {
    Object focusPath = getFocusRowKey();
    setRowKey(focusPath);
    // process stamp for one level
    HierarchyUtils.__processLevel(context, phaseId, this);
  }
  finally
  {
    setRowKey(oldPath);
  }

  // process the children
  TableUtils.__processChildren(context, this, phaseId);
}
 
Example 13
Project: myfaces-trinidad   File: UIXNavigationLevelTemplate.java   Source Code and License 6 votes vote down vote up
@Override
protected void processFacetsAndChildren(
  FacesContext context,
  PhaseId phaseId)
{
  Object oldPath = getRowKey();
  try
  {
    HierarchyUtils.__setStartDepthPath(this, getLevel());

    // process stamp for one level
    HierarchyUtils.__processLevel(context, phaseId, this);
  }
  finally
  {
    setRowKey(oldPath);
  }

  // process the children
  TableUtils.__processChildren(context, this, phaseId);
}
 
Example 14
Project: myfaces-trinidad   File: UIXSelectRangeTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * * We don't want to update model if we have validation errors
 * on the page, so if not immediate, queue the event in
 * INVOKE_APPLICATION phase.
 */
@Override
public void queueEvent(FacesEvent e)
{
  if ((e instanceof RangeChangeEvent) && (e.getSource() == this))
  {
    if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }

  super.queueEvent(e);
}
 
Example 15
Project: myfaces-trinidad   File: UIXNavigationTreeTemplate.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void processFacetsAndChildren(
  FacesContext context,
  PhaseId phaseId)
{
  // this component has no facets that need to be processed once.
  // instead process the "nodeStamp" facet as many times as necessary:
  Object oldPath = getRowKey();
  try
  {
    HierarchyUtils.__setStartDepthPath(this, getStartLevel());
    HierarchyUtils.__iterateOverTree(context,
                                      phaseId,
                                      this,
                                      getDisclosedRowKeys(),
                                      true);
  }
  finally
  {
    setRowKey(oldPath);
  }
}
 
Example 16
Project: myfaces-trinidad   File: UIXShowDetailTemplate.java   Source Code and License 6 votes vote down vote up
@Override
public void queueEvent(FacesEvent e)
{
  if ((e instanceof DisclosureEvent) && (e.getSource() == this))
  {
    if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }

  super.queueEvent(e);
}
 
Example 17
Project: myfaces-trinidad   File: UIXCommandTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * <p>Intercept <code>queueEvent</code> and mark the phaseId for the
 * event to be <code>PhaseId.APPLY_REQUEST_VALUES</code> if the
 * <code>immediate</code> flag is true,
 * <code>PhaseId.INVOKE_APPLICATION</code> otherwise.</p>
 */
@Override
public void queueEvent(FacesEvent e)
{
  if (this == e.getComponent() && ((e instanceof ActionEvent) || (e instanceof ReturnEvent)))
  {
    if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }

  super.queueEvent(e);
}
 
Example 18
Project: myfaces-trinidad   File: UIXSelectInputTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * <p>Intercept <code>queueEvent</code> and mark the phaseId for any
 * ActionEvents to be <code>PhaseId.APPLY_REQUEST_VALUES</code>.
 */
@Override
public void queueEvent(FacesEvent e)
{
  if (e instanceof ActionEvent)
  {
    // Always deliver ActionEvents immediately?
    //  if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    /*
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
      }*/
  }

  super.queueEvent(e);
}
 
Example 19
Project: spring4-understanding   File: DelegatingPhaseListenerTests.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 20
Project: libreacs   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 21
Project: development   File: CategorySelectionBean.java   Source Code and License 6 votes vote down vote up
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
        }
    };
}
 
Example 22
Project: watchout   File: PlayerSessionBean.java   Source Code and License 6 votes vote down vote up
/**
 * Can be used to render a image in the view with some image data
 * 
 * @param data
 *            array of bytes with image data
 * @return StreamedContent
 */
public StreamedContent getStreamedPhoto(byte[] data) {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent(FacesContext.getCurrentInstance()
				.getExternalContext()
				.getResourceAsStream("/static/img/default-image.png"));
		// return new DefaultStreamedContent();
	} else {
		if (data != null) {
			return new DefaultStreamedContent(
					new ByteArrayInputStream(data));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
Example 23
Project: watchout   File: GameBean.java   Source Code and License 6 votes vote down vote up
public StreamedContent getStreamedInsuranceIcon() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		String id = context.getExternalContext().getRequestParameterMap()
				.get("id");
		byte[] image = null;
		for (Insurances in : insurances) {
			if (in.getIdinsurances().toString().equals(id)) {
				image = in.getIcon();
				break;
			}
		}
		if (image != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					image));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
Example 24
Project: watchout   File: InsurancesBean.java   Source Code and License 6 votes vote down vote up
public StreamedContent getStreamedIcon() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		if (bean.getIcon() != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					bean.getIcon()));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
Example 25
Project: watchout   File: PlacesBean.java   Source Code and License 6 votes vote down vote up
public StreamedContent getStreamedPhoto() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		if (bean.getPhoto() != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					bean.getPhoto()));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
Example 26
Project: watchout   File: TransportsBean.java   Source Code and License 6 votes vote down vote up
public StreamedContent getStreamedIcon() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		if (bean.getIcon() != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					bean.getIcon()));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
Example 27
Project: BuildAndTestPattern4Xpages   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 28
Project: BuildAndTestPattern4Xpages   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 29
Project: class-guard   File: DelegatingPhaseListenerTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 30
Project: GeoprocessingAppstore   File: PrimaryPhaseListener.java   Source Code and License 6 votes vote down vote up
/**
 * 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); 
    
  }
}
 
Example 31
Project: xsp.extlib   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 32
Project: xsp.extlib   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 33
Project: sakai   File: EventPager.java   Source Code and License 6 votes vote down vote up
public void handleValueChange (ValueChangeEvent event)
{
    PhaseId
        phaseId = event.getPhaseId();

    String
        oldValue = (String) event.getOldValue(),
        newValue = (String) event.getNewValue();

    if (phaseId.equals(PhaseId.ANY_PHASE))
    {
        event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
        event.queue();
    }
    else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
    {
    // do you method here
    }
}
 
Example 34
Project: openacs   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 35
Project: maven-jdev-plugin   File: UIXCommandTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * <p>Intercept <code>queueEvent</code> and mark the phaseId for the
 * event to be <code>PhaseId.APPLY_REQUEST_VALUES</code> if the
 * <code>immediate</code> flag is true,
 * <code>PhaseId.INVOKE_APPLICATION</code> otherwise.</p>
 */
public void queueEvent(FacesEvent e)
{
  if (e instanceof ActionEvent)
  {
    if (isImmediate())
    {
      e.setPhaseId(PhaseId.ANY_PHASE);
    }
    else
    {
      e.setPhaseId(PhaseId.INVOKE_APPLICATION);
    }
  }

  super.queueEvent(e);
}
 
Example 36
Project: national-biomedical-image-archive   File: QcToolSearchBean.java   Source Code and License 6 votes vote down vote up
public void pageNumberChangeListener(ValueChangeEvent event)
{
	this.getDataTable().setFirst(0);


	/* To force the UI to show the updated values */
	if (event.getNewValue() != null ) {
		PhaseId phaseId = event.getPhaseId();

        if (phaseId.equals(PhaseId.ANY_PHASE))
        {
            event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
            event.queue();
        }
        else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
        {
        	String retValue = (String)event.getNewValue();

        	setSelectedDispItemNum(retValue);
        }
	}
}
 
Example 37
Project: national-biomedical-image-archive   File: DynamicSearchBean.java   Source Code and License 6 votes vote down vote up
public void permissibleDataChangeListener(ValueChangeEvent event) {
	if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
   		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
   		event.queue();
           return;
       }
	String someNewValue = (String)event.getNewValue();
	if(someNewValue.equals(defaultSelectValue)){
		//no change req.
	} else {
		this.permissibleDataValue = someNewValue;
		try {
			addCriteria();
			submitSearch();
			defaultView();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 38
Project: national-biomedical-image-archive   File: DynamicSearchBean.java   Source Code and License 6 votes vote down vote up
public void criteriaPermissibleDataChangeListener(ValueChangeEvent event) {
	if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
   		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
   		event.queue();
           return;
       }
	String someNewValue = (String)event.getNewValue();
	if(someNewValue.equals(defaultSelectValue)){
		//no change req.
	} else {
		//edit crieria
		try {
			editCriteria(event);
			criteria.clear();
			for (DynamicSearchCriteriaBean tmp:criteriaBean) {
				criteria.add(tmp.getCriteria());
			}
			hasDuplicate = false;
			submitSearch();
			defaultView();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 39
Project: national-biomedical-image-archive   File: SearchWorkflowBean.java   Source Code and License 6 votes vote down vote up
public void patientSelectChangeListener(ValueChangeEvent event) {

    	if(!editingSavedQuery)
    	{
    		setToggleQuery(true);
    	}

    	if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
    		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
    		event.queue();
            return;
        }
		try {
			logger.debug("patientSearch invoked");
			submitSearch();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
Example 40
Project: national-biomedical-image-archive   File: SearchWorkflowBean.java   Source Code and License 6 votes vote down vote up
public void baselineSelectChangeListener(ValueChangeEvent event) {

    	if(!editingSavedQuery)
    	{
    		setToggleQuery(true);
    	}

    	if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
    		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
    		event.queue();
            return;
        }
		try {
			logger.debug("baselineSearch invoked");
			submitSearch();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
Example 41
Project: national-biomedical-image-archive   File: SearchWorkflowBean.java   Source Code and License 6 votes vote down vote up
public void dateSelectChangeListener(ValueChangeEvent event) {

    	if(!editingSavedQuery)
    	{
    		setToggleQuery(true);
    	}

    	if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
    		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
    		event.queue();
            return;
        }
		try {
			logger.debug("dateSearch invoked");
			submitSearch();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
Example 42
Project: national-biomedical-image-archive   File: SearchWorkflowBean.java   Source Code and License 6 votes vote down vote up
public void resultPerPageOptionChangeListener(ValueChangeEvent event) {
  if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
 		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
 		event.queue();
         return;
     }
   String resultPerPageOptionNewValue = (String)event.getNewValue();
System.out.println("resultPerPageOption new value" + resultPerPageOptionNewValue);
this.resultPerPageOption = resultPerPageOptionNewValue;
try {
	submitSearch();
} catch (Exception e) {
	e.printStackTrace();
}

 }
 
Example 43
Project: national-biomedical-image-archive   File: SearchWorkflowBean.java   Source Code and License 6 votes vote down vote up
public void modalityAndAnyOptionChangeListener(ValueChangeEvent event) {
  if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) {
 		event.setPhaseId(PhaseId.INVOKE_APPLICATION);
 		event.queue();
         return;
     }
   String modalityAndedSearch = (String)event.getNewValue();
System.out.println("modalityAndedSearch new value" + modalityAndedSearch);
this.modalityAndedSearch = modalityAndedSearch;
try {
	submitSearch();
} catch (Exception e) {
	e.printStackTrace();
}

 }
 
Example 44
Project: org.openntf.domino   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
@Override
public void afterPhase(final 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);
}
 
Example 45
Project: org.openntf.domino   File: PhaseListener.java   Source Code and License 6 votes vote down vote up
@Override
public void beforePhase(final PhaseEvent arg0) {
	doBeforeEveryPhase(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);
	}
}
 
Example 46
Project: usgin-geoportal   File: PrimaryPhaseListener.java   Source Code and License 6 votes vote down vote up
/**
 * 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); 
    
  }
}
 
Example 47
Project: gae-java-template   File: SessionSerializationListener.java   Source Code and License 6 votes vote down vote up
@Override
public void afterPhase(PhaseEvent event)
{
    // Set an attribute on to the session just so that we can force the session to get serialized
    // We target the invoke application phase as well since the redirects get issued at that stage.
    if (event.getPhaseId() == PhaseId.INVOKE_APPLICATION || event.getPhaseId() == PhaseId.RENDER_RESPONSE)
    {
        final String METHOD_NAME = "afterPhase";
        LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, "Adding a random attribute to the session map.");
        Map<String, Object> sessionMap = event.getFacesContext().getExternalContext().getSessionMap();
        if (sessionMap != null)
        {
            sessionMap.put("__timestamp__", System.currentTimeMillis());
        }
    }
}
 
Example 48
Project: deltaspike   File: DeltaSpikePhaseListener.java   Source Code and License 6 votes vote down vote up
@Override
public void beforePhase(PhaseEvent phaseEvent)
{
    if (!this.activated)
    {
        return;
    }

    if (this.viewConfigResolver == null)
    {
        lazyInit();
    }

    processInitView(phaseEvent);

    //delegate to JsfRequestLifecyclePhaseListener as a last step
    this.jsfRequestLifecyclePhaseListener.beforePhase(phaseEvent);

    if (PhaseId.RENDER_RESPONSE.equals(phaseEvent.getPhaseId()))
    {
        onBeforeRenderResponse(phaseEvent.getFacesContext());
    }
}
 
Example 49
Project: deltaspike   File: DeltaSpikePhaseListener.java   Source Code and License 6 votes vote down vote up
private void processInitView(PhaseEvent event)
{
    if (event.getPhaseId().equals(PhaseId.RESTORE_VIEW) && !isRedirectRequest(event.getFacesContext()))
    {
        return;
    }

    //TODO check if we have to restrict the other callbacks as well
    //leads to a call of @BeforePhase but not the corresponding @AfterPhase call of the corresponding callbacks

    //TODO don't call the callbacks in case of an initial redirct
    //was:
    /*
    if(Boolean.TRUE.equals(event.getFacesContext().getExternalContext().getRequestMap()
            .get(WindowContextManagerObserver.INITIAL_REDIRECT_PERFORMED_KEY)))
    {
        return;
    }
    */

    FacesContext facesContext = event.getFacesContext();
    if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId() != null)
    {
        processInitView(event.getFacesContext().getViewRoot().getViewId());
    }
}
 
Example 50
Project: deltaspike   File: JsfRequestLifecycleBroadcaster.java   Source Code and License 6 votes vote down vote up
protected void broadcastBeforeEvent(PhaseEvent phaseEvent)
{
    //TODO discuss exception handling

    //fire to phase-observer methods
    this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), true)).fire(phaseEvent);
    this.beforeAnyPhaseEvent.fire(phaseEvent);

    //fire to ds-phase-listeners
    for (PhaseListener phaseListener : this.phaseListeners)
    {
        PhaseId targetPhase = phaseListener.getPhaseId();

        if (targetPhase == PhaseId.ANY_PHASE || targetPhase == phaseEvent.getPhaseId())
        {
            phaseListener.beforePhase(phaseEvent);
        }
    }
}
 
Example 51
Project: deltaspike   File: JsfRequestLifecycleBroadcaster.java   Source Code and License 6 votes vote down vote up
protected void broadcastAfterEvent(PhaseEvent phaseEvent)
{
    //TODO discuss exception handling

    //fire to phase-observer methods
    this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), false)).fire(phaseEvent);
    this.afterAnyPhaseEvent.fire(phaseEvent);

    //fire to ds-phase-listeners
    //call the listeners in reverse-order (like jsf)
    ListIterator<PhaseListener> phaseListenerIterator = this.phaseListeners.listIterator(phaseListeners.size());

    while (phaseListenerIterator.hasPrevious())
    {
        PhaseListener phaseListener = phaseListenerIterator.previous();
        PhaseId targetPhase = phaseListener.getPhaseId();

        if (targetPhase == PhaseId.ANY_PHASE || targetPhase == phaseEvent.getPhaseId())
        {
            phaseListener.afterPhase(phaseEvent);
        }
    }
}
 
Example 52
Project: javaee8-jsf-sample   File: MessageHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Handle a notification that the processing for a particular phase of the
 * request processing lifecycle is about to begin.
 */
public void beforePhase(PhaseEvent event) {

	if(event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
		FacesContext facesContext = event.getFacesContext();
		restoreMessages(facesContext);
	}
}
 
Example 53
Project: javaee8-jsf-sample   File: MessageHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Handle a notification that the processing for a particular phase has just
 * been completed.
 */
public void afterPhase(PhaseEvent event) {

	if(event.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES ||
			event.getPhaseId() == PhaseId.PROCESS_VALIDATIONS ||
			event.getPhaseId() == PhaseId.UPDATE_MODEL_VALUES || 
			event.getPhaseId() == PhaseId.INVOKE_APPLICATION) {

		FacesContext facesContext = event.getFacesContext();
		saveMessages(facesContext);
	}

}
 
Example 54
Project: oscm   File: MessageHandler.java   Source Code and License 5 votes vote down vote up
/**
 * in RENDER_RESPONSE restore facesMessages
 */
public void beforePhase(PhaseEvent event) {
    if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
        FacesContext facesContext = event.getFacesContext();
        restoreMessages(facesContext);
    }
}
 
Example 55
Project: oscm   File: MessageHandler.java   Source Code and License 5 votes vote down vote up
/**
 * save messages after APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS,
 * INVOKE_APPLICATION
 */
public void afterPhase(PhaseEvent event) {
    if (event.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES
            || event.getPhaseId() == PhaseId.PROCESS_VALIDATIONS
            || event.getPhaseId() == PhaseId.INVOKE_APPLICATION) {
        FacesContext facesContext = event.getFacesContext();
        saveMessages(facesContext);
    }
}
 
Example 56
Project: oscm   File: LocaleListener.java   Source Code and License 5 votes vote down vote up
public void beforePhase(PhaseEvent event) {
    PhaseId phaseId = event.getPhaseId();
    if (PhaseId.PROCESS_VALIDATIONS.equals(phaseId)
            || PhaseId.RENDER_RESPONSE.equals(phaseId)) {
        JSFUtils.verifyViewLocale();
    }
}
 
Example 57
Project: myfaces-trinidad   File: TrinidadComponentHandler.java   Source Code and License 5 votes vote down vote up
@Override
public void onComponentPopulated(FaceletContext context,
                                   UIComponent component,
                                   UIComponent parent)
{
  assert (_markInitialState != null);

  if ((component instanceof UIXComponent) &&
      (_markInitialState == Boolean.TRUE))
  {
    if (component.getId() == null)
      component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
    
    PhaseId phase = context.getFacesContext().getCurrentPhaseId();
    
    // In jsf2 markInitialState will be called by the framework during restore view, 
    // and in fact the framework should always be the one
    // calling markInitialState, but it doesn't always do that in render response, see
    // http://java.net/jira/browse/JAVASERVERFACES-2285
    // Also don't call markInitialState unless initialStateMarked returns false, otherwise
    // any deltas previously saved may get blown away.
    if (PhaseId.RENDER_RESPONSE.equals(phase) && !component.initialStateMarked())
    {
      component.markInitialState();
    }
  }
}
 
Example 58
Project: myfaces-trinidad   File: ViewDeclarationLanguageFactoryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void buildView(FacesContext facesContext, UIViewRoot uiViewRoot)
  throws IOException
{
  super.buildView(facesContext, uiViewRoot);
  if(PhaseId.RENDER_RESPONSE.equals(FacesContext.getCurrentInstance().getCurrentPhaseId()))
  {          
    ChangeManager cm = RequestContext.getCurrentInstance().getChangeManager();
    cm.applyComponentChangesForCurrentView(FacesContext.getCurrentInstance());
  }
}
 
Example 59
Project: myfaces-trinidad   File: TrinidadPhaseListener.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void afterPhase(PhaseEvent event)
{
  FacesContext context = event.getFacesContext();

  if (event.getPhaseId() == PhaseId.RESTORE_VIEW)
  {
    // Store off the current ViewRoot so we can check for a full page
    // render in response to a partial event.
    context.getExternalContext().getRequestMap().put(INITIAL_VIEW_ROOT_KEY,
                                                     context.getViewRoot());
  }
}
 
Example 60
Project: myfaces-trinidad   File: MVisitContextFactory.java   Source Code and License 5 votes vote down vote up
public static VisitContext createVisitContext(
 FacesContext       context,
 Collection<String> ids,
 Set<VisitHint>     hints,
 PhaseId            phaseId)
{
  return VisitTreeUtils.createVisitContext(context, ids, hints);
}