javax.faces.event.FacesEvent Java Examples

The following examples show how to use javax.faces.event.FacesEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UIVarPublisherBase.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof FacesEventWrapper) {
        FacesEventWrapper wrapper = (FacesEventWrapper) event;
        
        FacesContext context = getFacesContext();
        try {
            _shadowedData = publishControlData(context);
            
            FacesEvent original = wrapper.getFacesEvent();
            original.getComponent().broadcast(original);
        }
        finally {
            revokeControlData(_shadowedData, context);
            _shadowedData = null;
        }
    }
    else { // original event was queued on this control
        super.broadcast(event);
    }
}
 
Example #2
Source File: UISwitchFacet.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof FacetFacesEvent) {
    	FacetFacesEvent fe = (FacetFacesEvent)event;
    	UIComponent facet = selectFacet(fe.getFacetName()); 
    	if(facet!=null) {
    		try {
    			FacesEvent wrappedEvent = fe.getEvent();
                wrappedEvent.getComponent().broadcast(wrappedEvent);
    		} finally {
            	unselectFacet();
    		}
        }
    }
    else {
        super.broadcast(event);
    }
}
 
Example #3
Source File: AbstractPager.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
       super.broadcast(event);
       if (event instanceof PagerEvent) {
           //>tmg:a11y
           PagerEvent pe = (PagerEvent) event;
           FacesContext context = getFacesContext();
           if( pe instanceof ExtlibPagerEvent ){
               String focusClientId = ((ExtlibPagerEvent)pe).getClientId();
               if( null != focusClientId ){
                   HtmlUtil.storeEncodeParameter(context, this, PAGER_CLIENT_ID, focusClientId);
               }
           }
           //<tmg:a11y
           
           context.renderResponse();
       }
   }
 
Example #4
Source File: OpenStreetMap.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Queue an event for broadcast at the end of the current request processing
 * lifecycle phase. The default implementation in {@link UIComponentBase} must
 * delegate this call to the <code>queueEvent()</code> method of the parent
 * {@link UIComponent}.
 * </p>
 *
 * @param event {@link FacesEvent} to be queued
 *
 * @throws IllegalStateException if this component is not a descendant of a
 *                               {@link UIViewRoot}
 * @throws NullPointerException  if <code>event</code> is <code>null</code>
 */
public void queueEvent(FacesEvent event) {
	FacesContext context = FacesContext.getCurrentInstance();
	String indexes = (String) context.getExternalContext().getRequestParameterMap().get("indexes");
	context.getELContext().getELResolver().setValue(context.getELContext(), null, "indexes", indexes);
	String typeOfSelection = (String) context.getExternalContext().getRequestParameterMap().get("typeOfSelection");
	context.getELContext().getELResolver().setValue(context.getELContext(), null, "typeOfSelection",
			typeOfSelection);
	try {
		int oldIndex = getRowIndex();
		int index = Integer.valueOf(indexes);
		setRowIndex(index);
		super.queueEvent(event);
		setRowIndex(oldIndex);
	} catch (Exception multipleIndexes) {
		super.queueEvent(event);

	}
}
 
Example #5
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
public void queueEvent(FacesEvent event) {
	if (this.index >= 0) {
		super.queueEvent(new IndexedEvent(this, event, this.index));
	} else {
		super.queueEvent(event);
	}
}
 
Example #6
Source File: AudioUploadActionListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Get audio media upload path from the event's component tree.
 * @param ae  the event
 * @return
 */
private String getAudioMediaUploadPath(FacesEvent ae)
{
  String audioMediaUploadPath = null;

  // now find what component fired the event
  UIComponent component = ae.getComponent();
  // get the subview containing the audio question
  UIComponent parent = component.getParent();

  // get the its peer components from the parent
  List peers = parent.getChildren();

  // look for the correct file upload path information
  // held in the value of the component 'audioMediaUploadPath'
  for (int i = 0; i < peers.size(); i++)
  {
    UIComponent peer = (UIComponent) peers.get(i);

    if ("audioMediaUploadPath".equals(peer.getId()) && peer instanceof UIOutput)
    {
      audioMediaUploadPath = "" + ((UIOutput) peer).getValue();
      log.info("FOUND: Component " + i +
               " peer.getId(): " + peer.getId()+
               " peer.getValue(): " + audioMediaUploadPath );
      break;
    }
  }

  return audioMediaUploadPath;
}
 
Example #7
Source File: AbstractPager.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void queueEvent(FacesEvent e) {
       if (e instanceof PagerEvent) {
           if (isPartialExecute()) {
               e.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
           } else {
               e.setPhaseId(PhaseId.INVOKE_APPLICATION);
           }
       }
       super.queueEvent(e);
   }
 
Example #8
Source File: UIPagerSizes.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
       super.broadcast(event);
       if (event instanceof PagerEvent) {
           PagerEvent pe = (PagerEvent) event;
           switch (pe.getAction()) {
           	case ACTION_SETROWS: {
           		setRows(pe.getPage());
           	}
               break;
           }
       }
   }
 
Example #9
Source File: UIPagerAddRows.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
       super.broadcast(event);
       if (event instanceof PagerEvent) {
           PagerEvent pe = (PagerEvent) event;
           switch (pe.getAction()) {
           	case ACTION_ADDROWS: {
           		addRows();
           	} break;
           }
       }
   }
 
Example #10
Source File: UIDataSourceIterator.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
    public void queueEvent(FacesEvent event) {
        if ((event instanceof ToggleRowEvent) || (event instanceof ToggleDetailEvent)) {
            if (isPartialExecute()) {
                event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
            } else {
                event.setPhaseId(PhaseId.INVOKE_APPLICATION);
            }
            // We don't need to wrap it as this is just a command action to the table
            super.queueEvent(event);
        } else {
//            event = new FacesEventWrapper(this, event);
            super.queueEvent(event);
        }
    }
 
Example #11
Source File: UIPagerExpand.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
       super.broadcast(event);
       if (event instanceof PagerEvent) {
           PagerEvent pe = (PagerEvent) event;
           switch (pe.getAction()) {
           	case ACTION_EXPANDALL: {
           		expandAll();
           	} break;
           	case ACTION_COLLAPSEALL: {
           		collapseAll();
           	} break;
           }
       }
   }
 
Example #12
Source File: UIPagerDetail.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
       super.broadcast(event);
       if (event instanceof PagerEvent) {
           PagerEvent pe = (PagerEvent) event;
           switch (pe.getAction()) {
           	case ACTION_HIDEDETAIL: {
           		hideAll();
           	} break;
           	case ACTION_SHOWDETAIL: {
           		showAll();
           	} break;
           }
       }
   }
 
Example #13
Source File: DataTable.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Queue an event for broadcast at the end of the current request processing lifecycle phase. The default
 * implementation in {@link UIComponentBase} must delegate this call to the <code>queueEvent()</code> method of
 * the parent {@link UIComponent}.
 * </p>
 *
 * @param event {@link FacesEvent} to be queued
 *
 * @throws IllegalStateException if this component is not a descendant of a {@link UIViewRoot}
 * @throws NullPointerException if <code>event</code> is <code>null</code>
 */
@Override
public void queueEvent(FacesEvent event) {
	FacesContext context = FacesContext.getCurrentInstance();
	String indexes = (String) context.getExternalContext().getRequestParameterMap().get("indexes");
	context.getELContext().getELResolver().setValue(context.getELContext(), null, "indexes", indexes);
	String typeOfSelection = (String) context.getExternalContext().getRequestParameterMap().get("typeOfSelection");
	context.getELContext().getELResolver().setValue(context.getELContext(), null, "typeOfSelection", typeOfSelection);

	// https://datatables.net/reference/event/deselect#Description
	// split the array of indexes
	List<Integer> indexList = new ArrayList<>();
	if (null != indexes) {
		Matcher regexMatcher = Pattern.compile("(\\d+)").matcher(indexes);
		if (regexMatcher.find()) {
			indexList.add(Integer.valueOf(regexMatcher.group()));
		}
	}

	if (indexList.size() > 0) {
		// use the first index only
		int oldIndex = getRowIndex();
		setRowIndex(indexList.get(0));
		super.queueEvent(event);
		setRowIndex(oldIndex);
	} else {
		super.queueEvent(event);
	}
}
 
Example #14
Source File: AudioUploadActionListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Get audio media upload path from the event's component tree.
 * @param ae  the event
 * @return
 */
private String getAudioMediaUploadPath(FacesEvent ae)
{
  String audioMediaUploadPath = null;

  // now find what component fired the event
  UIComponent component = ae.getComponent();
  // get the subview containing the audio question
  UIComponent parent = component.getParent();

  // get the its peer components from the parent
  List peers = parent.getChildren();

  // look for the correct file upload path information
  // held in the value of the component 'audioMediaUploadPath'
  for (int i = 0; i < peers.size(); i++)
  {
    UIComponent peer = (UIComponent) peers.get(i);

    if ("audioMediaUploadPath".equals(peer.getId()) && peer instanceof UIOutput)
    {
      audioMediaUploadPath = "" + ((UIOutput) peer).getValue();
      log.info("FOUND: Component " + i +
               " peer.getId(): " + peer.getId()+
               " peer.getValue(): " + audioMediaUploadPath );
      break;
    }
  }

  return audioMediaUploadPath;
}
 
Example #15
Source File: Chart.java    From ChartistJSF with Apache License 2.0 5 votes vote down vote up
@Override
public void queueEvent(FacesEvent event) {
	if (event instanceof AjaxBehaviorEvent) {
		BehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
		Map<String, String> map = getFacesContext().getExternalContext().getRequestParameterMap();
		int itemIndex = Integer.parseInt(map.get("itemIndex"));
		int seriesIndex = Integer.parseInt(map.get("seriesIndex"));

		ItemSelectEvent itemSelectEvent = new ItemSelectEvent(this, behaviorEvent.getBehavior(), itemIndex,
				seriesIndex);

		super.queueEvent(itemSelectEvent);
	}
}
 
Example #16
Source File: UIComponentStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void queueEvent(FacesEvent arg0) {
    throw new UnsupportedOperationException();
}
 
Example #17
Source File: UIViewRootStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void broadcast(FacesEvent arg0) throws AbortProcessingException {
    throw new UnsupportedOperationException();
}
 
Example #18
Source File: UIInputStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void broadcast(FacesEvent arg0) throws AbortProcessingException {
    throw new UnsupportedOperationException();
}
 
Example #19
Source File: UIVarPublisherBase.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void queueEvent(FacesEvent event) {
    super.queueEvent(new FacesEventWrapper(this, event));
}
 
Example #20
Source File: UIInputStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void queueEvent(FacesEvent event) {
    throw new UnsupportedOperationException();
}
 
Example #21
Source File: UISwitchFacet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void queueEvent(FacesEvent event) {
    super.queueEvent(new FacetFacesEvent(this, event, getCurrentFacetName()));
}
 
Example #22
Source File: UISwitchFacet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public FacesEvent getEvent() {
    return _event;
}
 
Example #23
Source File: UISwitchFacet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public FacetFacesEvent(UIComponent component, FacesEvent event, String facetName) {
    super(component);
    _event = event;
    _facetName = facetName;
}
 
Example #24
Source File: UIComponentStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void broadcast(FacesEvent arg0) throws AbortProcessingException {
    throw new UnsupportedOperationException();
}
 
Example #25
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
public FacesEvent getTarget() {
	return target;
}
 
Example #26
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
public IndexedEvent(TabRepeat owner, FacesEvent target, int index) {
	super(owner);
	this.target = target;
	this.index = index;
}
 
Example #27
Source File: UIViewRootStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void queueEvent(FacesEvent arg0) {
    throw new UnsupportedOperationException();
}
 
Example #28
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
public void broadcast(FacesEvent event) throws AbortProcessingException {
	if (event instanceof IndexedEvent) {
		IndexedEvent idxEvent = (IndexedEvent) event;
		this.resetDataModel();
		int prevIndex = this.index;
		FacesContext ctx = FacesContext.getCurrentInstance();
		FacesEvent target = idxEvent.getTarget();
		UIComponent source = target.getComponent();
		UIComponent compositeParent = null;
		try {
			int rowCount = getDataModel().getRowCount();
			int idx = idxEvent.getIndex();
			this.setIndex(ctx, idx);
			Integer begin = this.getBegin();
			Integer end = this.getEnd();
			Integer step = this.getStep();
			int b = ((begin != null) ? begin : 0);
			int e = ((end != null) ? end : rowCount);
			int s = ((step != null) ? step : 1);
			this.updateIterationStatus(ctx,
					new IterationStatus(idx == b, (idx + s >= e || rowCount == 1), idx, begin, end, step));
			if (this.isIndexAvailable()) {
				if (!UIComponent.isCompositeComponent(source)) {
					compositeParent = UIComponent.getCompositeComponentParent(source);
				}
				if (compositeParent != null) {
					compositeParent.pushComponentToEL(ctx, null);
				}
				source.pushComponentToEL(ctx, null);
				source.broadcast(target);

			}
		} finally {
			source.popComponentFromEL(ctx);
			if (compositeParent != null) {
				compositeParent.popComponentFromEL(ctx);
			}
			this.updateIterationStatus(ctx, null);
			this.setIndex(ctx, prevIndex);
		}
	} else {
		super.broadcast(event);
	}
}
 
Example #29
Source File: AJAXBroadcastComponent.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * In addition to to the default {@link UIComponent#broadcast} processing,
 * pass the {@link ActionEvent} being broadcast to the method referenced by
 * <code>actionListener</code> (if any), and to the default
 * {@link ActionListener} registered on the
 * {@link javax.faces.application.Application}.
 * </p>
 *
 * @param event
 *            {@link FacesEvent} to be broadcast
 *
 * @throws AbortProcessingException
 *             Signal the JavaServer Faces implementation that no further
 *             processing on the current event should be performed
 * @throws IllegalArgumentException
 *             if the implementation class of this {@link FacesEvent} is not
 *             supported by this component
 * @throws NullPointerException
 *             if <code>event</code> is <code>null</code>
 */
@SuppressWarnings("deprecation")
public void broadcast(FacesEvent event) throws AbortProcessingException {

	// Perform standard superclass processing
	source.broadcast(event);
	if (event instanceof BootsFacesAJAXEvent) {
		Object result = executeAjaxCalls(FacesContext.getCurrentInstance(),
				((BootsFacesAJAXEvent) event).getJsCallback());
		// if (result != null) {
		// System.out.println("Redirection has not yet been implemented.");
		// }
	}
}