Java Code Examples for javax.faces.event.ActionEvent

The following are top voted examples for showing how to use javax.faces.event.ActionEvent. 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: exmatrikulator   File: TutorialEventController.java   Source Code and License 7 votes vote down vote up
/**
 * Adds a new event to the tutorial event.
 * @param actionEvent The actionEvent triggered by the PrimeFaces scheduler.
 */
public void addEvent(ActionEvent actionEvent) {
    log.debug("addEvent called with " + actionEvent);
    if (event.getId() == null) {
        tutorialEventModel.addEvent(event);
        log.debug("Event gets added");
        logEventCreated(event);
    } else {
        tutorialEventModel.updateEvent(event);
        log.debug("Event gets updated");
        if (event.getStartDate() != oldEventStartDate
                || event.getEndDate() != oldEventEndDate) {
            log.debug("The event dates have changed");
            logEventMoved(event);
            mailEventMoved(event, oldEventStartDate, oldEventEndDate);
        } else {
            logEventUpdated(event);
        }
    }
    updateTutorialEvents();
    event = new TutorialEvent();
}
 
Example 2
Project: exmatrikulator   File: ExamEventController.java   Source Code and License 7 votes vote down vote up
/**
 * Adds a new event to the exam event.
 * @param actionEvent The actionEvent triggered by the PrimeFaces scheduler.
 * @pre The selected event is not null.
 */
public void addEvent(ActionEvent actionEvent) {
    if (event.getId() == null) {
        updateExaminedStudentsFromDualList();
        event = examEventService.persist(event);
        examEventModel.addEvent(event);
        log.debug("Event gets added");
        logEventCreated(event);
    } else {
        updateExaminedStudentsFromDualList();;
        examEventModel.updateEvent(event);
        log.debug("Event gets updated");

        if ((oldEventEndDate != null && oldEventStartDate != null)
                && (!event.getStartDate().equals(oldEventStartDate)
                || !event.getEndDate().equals(oldEventEndDate))) {
            logEventMoved(event);
            mailEventMoved(event, oldEventStartDate, oldEventEndDate);
        } else {
            logEventUpdated(event);
        }
    }
    updateExamEvents();
    event = createDefaultEvent();
}
 
Example 3
Project: myfaces-trinidad   File: ProgressRenderer.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void decode(FacesContext context, UIComponent component)
{
  UIXProgress progressComponent = (UIXProgress)component;
  Map<String, Object> attrs = component.getAttributes();

  Object modelValue= attrs.get(UIConstants.VALUE_PARAM);
  if (modelValue instanceof BoundedRangeModel)
  {
    BoundedRangeModel model = (BoundedRangeModel) modelValue;
    if (model != null)
    {
      long value = model.getValue();
      long maximum = model.getMaximum();
      if (maximum <= value)
      //pu: This means the background task is complete.
      {
        (new ActionEvent(progressComponent)).queue();
      }
    }
  }
}
 
Example 4
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License 6 votes vote down vote up
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]
    { event });
  }

}
 
Example 5
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License 6 votes vote down vote up
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]{ event });
  }

}
 
Example 6
Project: myfaces-trinidad   File: TableBean.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void performReport(ActionEvent action)
{
  UIXCollection table = (UIXCollection) _table;
  final RowKeySet state;
  if (table instanceof UIXTable)
    state = ((UIXTable) table).getSelectedRowKeys();
  else
    state = ((UIXTree) table).getSelectedRowKeys();
  Iterator<Object> selection = state.iterator();
  Object oldKey = table.getRowKey();
  _selection = new ArrayList<Object>();
  while (selection.hasNext())
  {
    table.setRowKey(selection.next());
    _selection.add(table.getRowData());
  }
  table.setRowKey(oldKey);
  FacesContext context = FacesContext.getCurrentInstance();
  FacesMessage message =
    new FacesMessage("Report Performed","Report was performed on "+
                     _selection.size()+" records");
  context.addMessage(null, message);
}
 
Example 7
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Modifies the sortable property of the column.
 */
@SuppressWarnings("unchecked")
public void modifyColumn(ActionEvent event)
{
  //=-=pu: 'uic1' gets null, while 'uic' gets valid component, maybe a bug ?.
  //UIComponent uic1 = event.getComponent().findComponent("c1");
  UIComponent uic2 = event.getComponent().findComponent("t1");
  UIComponent uic = uic2.findComponent("c1");
  
  Object sortableAttrib = uic.getAttributes().get("sortable");
  Boolean isSortable = 
    (sortableAttrib == null)? Boolean.TRUE:(Boolean)sortableAttrib;
  Boolean newSortableValue = 
    Boolean.TRUE.equals(isSortable)? Boolean.FALSE:Boolean.TRUE;
  uic.getAttributes().put("sortable", newSortableValue);
  _addAttributeChange(uic, "sortable", newSortableValue);
}
 
Example 8
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Appends an image child to the panelGroup in the underlying JSP document
 */
public void appendChildToDocument(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  
  // only allow the image to be added once
  if (_findChildById(uic,"oi3") != null)
    return;
    
  FacesContext fc = FacesContext.getCurrentInstance();

  DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
  
  if (imageFragment != null)
  {
    DocumentChange change = new AddChildDocumentChange(imageFragment);
    
    ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
    
    apm.addDocumentChange(fc, uic, change);
  }
}
 
Example 9
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Appends an image child to the panelGroup.
 */
@SuppressWarnings("unchecked")
public void appendChild(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  if (_findChildById(uic,"oi2") != null)
    return;
  FacesContext fc = FacesContext.getCurrentInstance();
  
  CoreImage newChild = 
    (CoreImage) fc.getApplication().createComponent(
      "org.apache.myfaces.trinidad.CoreImage");
  newChild.setId("oi2");
  newChild.setInlineStyle("height: 100px, width: 120px");
  newChild.setSource(
    "http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg");  
  uic.getChildren().add(newChild);

  ComponentChange aca = new AddChildComponentChange(newChild);

  ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
  apm.addComponentChange(fc, uic, aca);
}
 
Example 10
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Adds a 'brandingAppContextual' facet  to the panelGroup.
 */
@SuppressWarnings("unchecked")
public void addFacet(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pp1");
  FacesContext fc = FacesContext.getCurrentInstance();
  CoreOutputFormatted newFacetComponent = 
    (CoreOutputFormatted) fc.getApplication().createComponent(
      "org.apache.myfaces.trinidad.CoreOutputFormatted");
  newFacetComponent.setStyleUsage("inContextBranding" );
  newFacetComponent.setValue(
    "Customer Company - Menlo Park");
  uic.getFacets().put("brandingAppContextual", newFacetComponent);

  ComponentChange afa = new SetFacetChildComponentChange("brandingAppContextual", newFacetComponent);

  ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
  apm.addComponentChange(fc, uic, afa);
}
 
Example 11
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Reverses the order of children of the panelGroup.
 */
@SuppressWarnings("unchecked")
public void reorderChildren(ActionEvent event)
{
  UIComponent uic = event.getComponent().findComponent("pg1");
  int numChildren = uic.getChildCount();
  if (numChildren == 0)
    return;
  List<UIComponent> children = uic.getChildren();
  Collections.reverse(children);
  List<String> reorderedChildIdList = new ArrayList<String>();
  for(UIComponent child : children)
  {
    reorderedChildIdList.add(child.getId());
  }
  
  ComponentChange ra = new ReorderChildrenComponentChange(reorderedChildIdList);

  FacesContext fc = FacesContext.getCurrentInstance();
  ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
  apm.addComponentChange(fc, uic, ra);
}
 
Example 12
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Removes a pair of children, based on some characteristic of the
 *  event source.
 */
public void removeChildren(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  int numChildren = uic.getChildCount();
  if (numChildren == 0)
    return;
  String eventSourceId = eventSource.getId();    
  if (eventSourceId.equals("cb2"))
  {
    _removeChild(uic, "sic1");
    _removeChild(uic, "cc1");
  }
  else if (eventSourceId.equals("cb3"))
  {
    _removeChild(uic, "cd1");
    _removeChild(uic, "sid1");
  }
}
 
Example 13
Project: myfaces-trinidad   File: DynamicBean.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public CorePanelBox getPanel()
{
  if (_panel == null)
  {
    FacesContext context = FacesContext.getCurrentInstance();

    _panel = new CorePanelBox();
    CoreCommandLink link = new CoreCommandLink();
    link.setText("Dynamic Link");

    MethodBinding actionListenerMethod = context.getApplication().
        createMethodBinding("#{dynamic.doSomething}",
                            new Class[]{ActionEvent.class}); 
    link.setActionListener(actionListenerMethod); 
    link.setId("TheLinkId");
    _panel.getChildren().add(link);
  }

  return _panel;
}
 
Example 14
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License 6 votes vote down vote up
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]
    { event });
  }

}
 
Example 15
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License 6 votes vote down vote up
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]{ event });
  }

}
 
Example 16
Project: myfaces-trinidad   File: UIXProgressTemplate.java   Source Code and License 6 votes vote down vote up
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException
{
  super.broadcast(event);

  // Notify the specified action listener method (if any),
  // and the default action listener
  if (event instanceof ActionEvent)
  {
    FacesContext context = getFacesContext();
    MethodBinding mb = getActionListener();
    if (mb != null)
      mb.invoke(context, new Object[] { event });

    ActionListener defaultActionListener =
      context.getApplication().getActionListener();
    if (defaultActionListener != null)
    {
      defaultActionListener.processAction((ActionEvent) event);
    }
  }
}
 
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: ctsms   File: ResetInputAjaxActionListener.java   Source Code and License 6 votes vote down vote up
/**
 * Handle the reset input action as follows, only and only if the current request is an ajax request and the
 * {@link PartialViewContext#getRenderIds()} does not return an empty collection nor is the same as
 * {@link PartialViewContext#getExecuteIds()}: find all {@link EditableValueHolder} components based on
 * {@link PartialViewContext#getRenderIds()} and if the component is not covered by
 * {@link PartialViewContext#getExecuteIds()}, then invoke {@link EditableValueHolder#resetValue()} on the
 * component.
 * @throws IllegalArgumentException When one of the client IDs resolved to a <code>null</code> component. This
 * would however indicate a bug in the concrete {@link PartialViewContext} implementation which is been used.
 */
@Override
public void processAction(ActionEvent event) throws AbortProcessingException {
	FacesContext context = FacesContext.getCurrentInstance();
	PartialViewContext partialViewContext = context.getPartialViewContext();

	if (partialViewContext.isAjaxRequest()) {
		Collection<String> renderIds = getRenderIds(partialViewContext);

		if (!renderIds.isEmpty() && !partialViewContext.getExecuteIds().containsAll(renderIds)) {
			context.getViewRoot().visitTree(createVisitContext(context, renderIds, VISIT_HINTS), VISIT_CALLBACK);
		}
	}

	if (wrapped != null && event != null) {
		wrapped.processAction(event);
	}
}
 
Example 20
Project: Peking-University-Open-Research-Data-Platform   File: RolePermissionFragment.java   Source Code and License 6 votes vote down vote up
public void updateRole(ActionEvent e) {
    // @todo currently only works for Dataverse since CreateRoleCommand only takes a dataverse
    // we need to decide if we want roles at the dataset level or not
    if (dvObject instanceof Dataverse) {
        role.clearPermissions();
        for (String pmsnStr : getSelectedPermissions()) {
            role.addPermission(Permission.valueOf(pmsnStr));
        }
        try {
            setRole(commandEngine.submit(new CreateRoleCommand(role, session.getUser(), (Dataverse) role.getOwner())));
            JH.addMessage(FacesMessage.SEVERITY_INFO, "Role '" + role.getName() + "' saved", "");
        } catch (CommandException ex) {
            JH.addMessage(FacesMessage.SEVERITY_ERROR, "Cannot save role", ex.getMessage());
            logger.log(Level.SEVERE, "Saving role failed", ex);
        }
    }
}
 
Example 21
Project: rpb   File: SoftwareBean.java   Source Code and License 6 votes vote down vote up
/**
 * Update selected software in repository
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doUpdateSoftware(ActionEvent actionEvent){
    FacesContext context = FacesContext.getCurrentInstance();

    try {
        // Commit changes
        PartnerSite partnerSite = new PartnerSite();
        partnerSite.setIdentifier(this.messageUtil.getResourcesUtil().getProperty("partner_site_identifier"));
        Portal portal = this.partnerSiteRepository.findUnique(partnerSite).getPortal();
        portal.removeSoftware(this.selectedEntity);
        portal.addSoftware(this.selectedEntity);
        this.portalRepository.merge(portal);
        context.addMessage(null, new FacesMessage("Edit Successful", "Software: " + this.selectedEntity.getName() + " successfuly saved."));

        // Reload actual
        this.loadSoftware();
    }
    catch (Exception err) {
        context.addMessage(null, new FacesMessage("Error", err.getMessage()));
    }
}
 
Example 22
Project: rpb   File: SoftwareBean.java   Source Code and License 6 votes vote down vote up
/**
 * Delete selected software from repository
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doDeleteSoftware(ActionEvent actionEvent){
    FacesContext context = FacesContext.getCurrentInstance();

    try {
        // Delete
        PartnerSite partnerSite = new PartnerSite();
        partnerSite.setIdentifier(this.messageUtil.getResourcesUtil().getProperty("partner_site_identifier"));
        Portal portal = this.partnerSiteRepository.findUnique(partnerSite).getPortal();
        portal.removeSoftware(this.selectedEntity);
        this.portalRepository.merge(portal);

        context.addMessage(null, new FacesMessage("Delete Successful", "Software: " + this.selectedEntity.getName() + " successfuly deleted."));

        this.selectedEntity = null;

        // Reload actual
        this.loadSoftware();
    }
    catch (Exception err) {
        context.addMessage(null, new FacesMessage("Error", err.getMessage()));
    }
}
 
Example 23
Project: rpb   File: CrfAnnotationBean.java   Source Code and License 6 votes vote down vote up
/**
 * Update existing eCRF field annotation
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doUpdateAnnotation(ActionEvent actionEvent){
    try {
        this.studyRepository.merge(this.rpbStudy);

        this.messageUtil.infoText("Edit Successful: Annotation for eCRF field: " +
                this.selectedEntity.getCrfItemOid() +
                " successfuly updated.");

        // Reload annotations form DB
        this.loadCrfFieldAnnotations();
    }
    catch (Exception err) {
        this.messageUtil.error(err);
    }
}
 
Example 24
Project: rpb   File: CrfAnnotationBean.java   Source Code and License 6 votes vote down vote up
/**
 * Delete existing eCRF field annotation
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doDeleteAnnotation(ActionEvent actionEvent){
    try {
        this.rpbStudy.removeCrfFieldAnnotation(this.selectedEntity);
        this.studyRepository.merge(this.rpbStudy);

        this.messageUtil.infoText("Delete Successful: Annotation for eCRF field: " +
                this.selectedEntity.getCrfItemOid() +
                " successfuly deleted.");

        // Reload annotations form DB
        this.loadCrfFieldAnnotations();
    }
    catch (Exception err) {
        this.messageUtil.error(err);
    }
}
 
Example 25
Project: myWMS   File: JSFHelper.java   Source Code and License 6 votes vote down vote up
public void actionPerformed(java.awt.event.ActionEvent e) {
            System.out.println("timer run2 xxxxxxxxxxxxxxxxxxxxxxx");
            FacesContext fc = javax.faces.context.FacesContext.getCurrentInstance();
            Object obj = fc.getExternalContext().getSession(false);
                System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxx timer xx  "+fc.getExternalContext().getSession(false)+"  "+javax.faces.context.FacesContext.getCurrentInstance());            
            if (obj == null) {
                System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxx loged out xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
                timer.stop();
/*                Application ap = fc.getApplication();
                NavigationHandler nh = ap.getNavigationHandler();
                List<String> buttonTextList = new ArrayList<String>();
                buttonTextList.add(resolve("Login", new Object[]{}));
                NotifyDescriptorExt n = new NotifyDescriptorExt(Constants.INFORMATION_ICON, resolve("SessionTimeout", new Object[]{}), resolve("LogoutMessage", new Object[]{}), buttonTextList);
                String page = n.setCallbackListener(new ButtonListener() {

                    public String buttonClicked(final int buttonId) {
                        return NavigationEnum.controller_CenterPanel.toString();
                    }
                });
                nh.handleNavigation(fc, null, page);*/
            }
        }
 
Example 26
Project: linkbinder   File: PreValidateEventListener.java   Source Code and License 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example 27
Project: master_informatica-DSS   File: ControladorMotor.java   Source Code and License 6 votes vote down vote up
public void actualizarBtnOnOff(ActionEvent e) {
	switch (estado) {
	case APAGADO:
		encender();
		break;
	case ENCENDIDO:
		apagar();
		break;
	case ACELERANDO:
		apagar();
		break;
	default:
		// idle
		break;
	}
}
 
Example 28
Project: master_informatica-DSS   File: ControladorMotor.java   Source Code and License 6 votes vote down vote up
public void actualizarBtnAcelerar(ActionEvent e) {
	switch (estado) {
	case APAGADO:
		// idle
		break;
	case ENCENDIDO:
		acelerar();
		break;
	case ACELERANDO:
		acelerar();
		break;
	default:
		// idle
		break;
	}
}
 
Example 29
Project: Pecomp   File: SimuladoAleatorioBean.java   Source Code and License 6 votes vote down vote up
public void enviarResposta(ActionEvent actionEvent){
	
	if(alternativaSelecionada != null){
		QuestaoOpcao opcaoSel = questaoOpcaoRepository.getById(alternativaSelecionada);
		Questao questaoRespondida = opcaoSel.getQuestao();
		Pessoa usuario = loginBean.getUsuario();
		
		PessoaAcertos correcao = new PessoaAcertos(usuario, questaoRespondida, opcaoSel.getGabarito());
		pessoaAcertosRepository.inserir(correcao);		
		
		//validacoes nao estao aparecendo na tela
		if(opcaoSel.getGabarito() == true){
			this.sucess("Resposta correta!");
		}else{
			this.error("Resposta errada!");
		}
	}else{
		this.error("Selecione uma alternativa");
	}
	
}
 
Example 30
Project: Pecomp   File: SimuladoDisciplinaBean.java   Source Code and License 6 votes vote down vote up
public void enviarResposta(ActionEvent actionEvent){
	
	if(alternativaSelecionada != null){
		QuestaoOpcao opcaoSel = questaoOpcaoRepository.getById(alternativaSelecionada);
		Questao questaoRespondida = opcaoSel.getQuestao();
		Pessoa usuario = loginBean.getUsuario();
		
		PessoaAcertos correcao = new PessoaAcertos(usuario, questaoRespondida, opcaoSel.getGabarito());
		pessoaAcertosRepository.inserir(correcao);		
		
		//validacoes nao estao aparecendo na tela
		if(opcaoSel.getGabarito()){
			this.sucess("Resposta correta!");
		}else{
			this.error("Resposta errada!");
		}
	}else{
		this.error("Selecione uma alternativa");
	}
	
}
 
Example 31
Project: Pecomp   File: SimuladoAnoBean.java   Source Code and License 6 votes vote down vote up
public void enviarResposta(ActionEvent actionEvent){
	
	if(alternativaSelecionada != null){
		QuestaoOpcao opcaoSel = questaoOpcaoRepository.getById(alternativaSelecionada);
		Questao questaoRespondida = opcaoSel.getQuestao();
		Pessoa usuario = loginBean.getUsuario();
		
		PessoaAcertos correcao = new PessoaAcertos(usuario, questaoRespondida, opcaoSel.getGabarito());
		pessoaAcertosRepository.inserir(correcao);		
		
		//validacoes nao estao aparecendo na tela
		if(opcaoSel.getGabarito()){
			this.sucess("Resposta coreta!");
		}else{
			this.error("Resposta errada!");
		}
	}else{
		this.error("Selecione uma alternativa");
	}
	
}
 
Example 32
Project: jpasecurity   File: CancelActionListener.java   Source Code and License 6 votes vote down vote up
public void processAction(ActionEvent actionEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    UINamingContainer loginComponent
        = (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
    MethodExpression loginAction = (MethodExpression)loginComponent.getAttributes().get("cancelAction");
    try {
        loginAction.invoke(context.getELContext(), new Object[] {});
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Login-cancellation could not be fulfilled.", e);
        } else {
            LOG.info("Login-cancellation could not be fulfilled: " + e.getMessage());
        }
    }
    NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
    String outcome = (String)context.getExternalContext().getRequestParameterMap().get("outcome");
    if (outcome != null) {
        navigationHandler.handleNavigation(context, null, outcome);
    }
}
 
Example 33
Project: jpasecurity   File: LoginActionListener.java   Source Code and License 6 votes vote down vote up
public void processAction(ActionEvent actionEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    UINamingContainer loginComponent
        = (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
    UIInput username = (UIInput)loginComponent.findComponent("loginDialog:loginForm:username");
    UIInput password = (UIInput)loginComponent.findComponent("loginDialog:loginForm:password");
    MethodExpression loginAction = (MethodExpression)loginComponent.getAttributes().get("loginAction");
    try {
        loginAction.invoke(context.getELContext(), new Object[] {username.getValue(), password.getValue()});
        NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
        String outcome = (String)context.getExternalContext().getRequestParameterMap().get("outcome");
        if (outcome != null) {
            navigationHandler.handleNavigation(context, null, outcome);
        }
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Login could not be established.", e);
        } else {
            LOG.info("Login could not be established: " + e.getMessage());
        }
    }
}
 
Example 34
Project: exmatrikulator   File: ExamEventController.java   Source Code and License 6 votes vote down vote up
/**
 * Removes the selected exam event.
 * @param actionEvent The actionEvent triggered by the PrimeFaces scheduler.
 */
public void removeEvent(ActionEvent actionEvent) {
    log.debug("removeEvent called with " + actionEvent);
    if (examEventModel.getEvents().contains(event)) {
        log.debug("Removing the event from the EventModel");
        PrivilegedUser examiner = event.getExaminer();
        examiner.getExamEvents().remove(event);
        privilegedUserService.update(examiner);

        List<Student> oldExaminedStudents = event.getExaminedStudents();
        for (Student student: oldExaminedStudents) {
            student.getExamEvents().remove(event);
        }
        event.getExaminedStudents().clear();
        studentService.update(oldExaminedStudents);
        examEventModel.deleteEvent(event);
        logEventRemoved(event);
    }
    updateExamEvents();
    event = createDefaultEvent();
}
 
Example 35
Project: vocloud   File: JobsBean.java   Source Code and License 6 votes vote down vote up
public void download(ActionEvent e) throws IOException {
    File file = (File) e.getComponent().getAttributes().get("selectedFile");
    logger.info("Downloading " + file.getAbsolutePath());
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();

    response.reset();
    response.setContentType(externalContext.getMimeType(file.getName()));
    response.setHeader("Content-disposition", "attachment; filename=\"" + file.getName() + "\"");

    try (BufferedOutputStream output = new BufferedOutputStream(response.getOutputStream());
            BufferedInputStream input = new BufferedInputStream(new FileInputStream(file))) {
        byte[] buffer = new byte[10240];
        for (int length; (length = input.read(buffer)) > 0;) {
            output.write(buffer, 0, length);
        }
    }

    facesContext.responseComplete();
}
 
Example 36
Project: rpb   File: SoftwareBean.java   Source Code and License 6 votes vote down vote up
/**
 * Update selected software in repository
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doUpdateSoftware(ActionEvent actionEvent){
    FacesContext context = FacesContext.getCurrentInstance();

    try {
        // Commit changes
        PartnerSite partnerSite = new PartnerSite();
        partnerSite.setIdentifier(this.messageUtil.getResourcesUtil().getProperty("partner_site_identifier"));
        Portal portal = this.partnerSiteRepository.findUnique(partnerSite).getPortal();
        portal.removeSoftware(this.selectedEntity);
        portal.addSoftware(this.selectedEntity);
        this.portalRepository.merge(portal);
        context.addMessage(null, new FacesMessage("Edit Successful", "Software: " + this.selectedEntity.getName() + " successfuly saved."));

        // Reload actual
        this.loadSoftware();
    }
    catch (Exception err) {
        context.addMessage(null, new FacesMessage("Error", err.getMessage()));
    }
}
 
Example 37
Project: rpb   File: SoftwareBean.java   Source Code and License 6 votes vote down vote up
/**
 * Delete selected software from repository
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doDeleteSoftware(ActionEvent actionEvent){
    FacesContext context = FacesContext.getCurrentInstance();

    try {
        // Delete
        PartnerSite partnerSite = new PartnerSite();
        partnerSite.setIdentifier(this.messageUtil.getResourcesUtil().getProperty("partner_site_identifier"));
        Portal portal = this.partnerSiteRepository.findUnique(partnerSite).getPortal();
        portal.removeSoftware(this.selectedEntity);
        this.portalRepository.merge(portal);

        context.addMessage(null, new FacesMessage("Delete Successful", "Software: " + this.selectedEntity.getName() + " successfuly deleted."));

        this.selectedEntity = null;

        // Reload actual
        this.loadSoftware();
    }
    catch (Exception err) {
        context.addMessage(null, new FacesMessage("Error", err.getMessage()));
    }
}
 
Example 38
Project: rpb   File: CrfAnnotationBean.java   Source Code and License 6 votes vote down vote up
/**
 * Delete existing eCRF field annotation
 * @param actionEvent action event
 */
@SuppressWarnings("unused")
public void doDeleteAnnotation(ActionEvent actionEvent){
    try {
        this.rpbStudy.removeCrfFieldAnnotation(this.selectedEntity);
        this.studyRepository.merge(this.rpbStudy);

        this.messageUtil.infoText("Delete Successful: Annotation for eCRF field: " +
                this.selectedEntity.getCrfItemOid() +
                " successfuly deleted.");

        // Reload annotations form DB
        this.loadCrfFieldAnnotations();
    }
    catch (Exception err) {
        this.messageUtil.error(err);
    }
}
 
Example 39
Project: sakai   File: SpreadsheetUploadBean.java   Source Code and License 6 votes vote down vote up
/**
   * Process an upload ActionEvent from spreadsheetUpload.jsp or spreadsheetEntireGBImport.jsp
   * Source of this action is the Upload button on either page
   *
   * @param event
   */
  public void launchFilePicker(ActionEvent event) {
try  {
	String titleText = FacesUtil.getLocalizedString("upload_view_page_title");
	String instructionText = FacesUtil.getLocalizedString("upload_view_instructions_text");

	ToolSession currentToolSession = SessionManager.getCurrentToolSession();
       // SAK-14173 - store title
       currentToolSession.setAttribute(IMPORT_TITLE, this.title);
	currentToolSession.setAttribute(FilePickerHelper.FILE_PICKER_MAX_ATTACHMENTS, FilePickerHelper.CARDINALITY_SINGLE);
	currentToolSession.setAttribute(FilePickerHelper.FILE_PICKER_TITLE_TEXT, titleText);
	currentToolSession.setAttribute(FilePickerHelper.FILE_PICKER_INSTRUCTION_TEXT, instructionText);
	currentToolSession.setAttribute(FilePickerHelper.FILE_PICKER_RESOURCE_FILTER,
		ComponentManager.get("org.sakaiproject.content.api.ContentResourceFilter.spreadsheetCsvFile"));
	ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
	context.redirect("sakai.filepicker.helper/tool");
}
catch(Exception e) {
	log.error(this + ".launchFilePicker - " + e);
}
  }
 
Example 40
Project: hopsworks   File: AddHostController.java   Source Code and License 6 votes vote down vote up
public void addHost(ActionEvent actionEvent) {
  FacesContext context = FacesContext.getCurrentInstance();
  FacesMessage msg;
  if (hostEJB.hostExists(hostId)) {
    logger.log(Level.INFO, "Host with id {0} already exists.", hostId);
    msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Host Exists",
            "A host with id " + hostId + " already exists.");
    context.addMessage(null, msg);
  } else {
    Hosts host = new Hosts();
    host.setHostname(hostId);
    host.setPrivateIp(privateIp);
    host.setPublicIp(publicIp);
    host.setHostIp("");
    hostEJB.storeHost(host, true);
    RequestContext reqInstace = RequestContext.getCurrentInstance();
    reqInstace.addCallbackParam("hostadded", true);
    msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Host Added",
            "Host " + hostId + " added successfully.");
    context.addMessage(null, msg);
    resetValues();
  }
}