Package org.primefaces.context

Examples of org.primefaces.context.RequestContext


  }

  public String add(){
    String result=UserService.adaugaStudent(this);
    if(result.equals("student existent")){
    RequestContext context = RequestContext.getCurrentInstance();
    context.execute("dlg4.hide();");
   
        }
    return null;

  }
View Full Code Here


     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void BookEvent(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        FacesMessage msg = null;
        boolean bIsEventBooked = false;

        try {

            OrderDTO order = _orderWebService.getOrderServiceImplPort().placeOrder(
                    getCurrentOrder().getEventDetail().getEventData(),
                    getCurrentOrder().getCustomerProfile().getProfileData(),
                    getCurrentOrder().getOrderData().getShippingAddress(),
                    getCurrentOrder().getOrderData().getBillingAddress(),
                    getCurrentOrder().getOrderData().getOrderQuantity()
            );

            if (order.getReturncode() == 0) {

                bIsEventBooked = true;
                _newOrder = null;

                msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Order accepted",
                        String.format("Order created: %s", order.getId()));               
            } else {

                bIsEventBooked = false;

                msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Order rejected",
                        order.getMessage());
            }

        } catch (Exception ex) {

            bIsEventBooked = false;

            msg = new FacesMessage(FacesMessage.SEVERITY_FATAL, "Error communicating with order web service!",
                    String.format("Unable to access order web service at %s: %s",
                            _orderWebService.getWSDLDocumentLocation(),
                            ex.getMessage()));
        }

        if (msg != null)
            FacesContext.getCurrentInstance().addMessage(null, msg);

        ctx.addCallbackParam("booked", bIsEventBooked);

        SystemController.redirectUrl(ctx, "index");
    }
View Full Code Here

     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void CancelBooking(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();

        _newOrder = null;

        SystemController.redirectUrl(ctx, "index");
    }
View Full Code Here

     * @param userProfile the customer who is going to place the order
     * @param eventDetail the event for which the order is placed
     */
    public void PrepareNewOrder(UserProfile userProfile, EventDetail eventDetail) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        GregorianCalendar calendar = (GregorianCalendar) GregorianCalendar.getInstance();
        calendar.setTime(new Date());

        XMLGregorianCalendar xCal = null;

View Full Code Here

     *
     * @param order the order which should be canceled
     */
    public void CancelOrder(OrderDetail order) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        FacesMessage msg = null;

        try {

            BaseDTO result = _orderWebService.getOrderServiceImplPort().cancelOrder(order.getOrderData());
View Full Code Here

     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void Login(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        FacesMessage msg = null;
        boolean bIsLoggedIn = false;

        try {

            CustomerDTO _customerDTO = _customerWebService.getCustomerServiceImplPort().signOn(
                    this.getLogonCredentials().getUserName(), this.getLogonCredentials().getPassword());

            if (_customerDTO.getReturncode() == 0) {

                bIsLoggedIn = true;
                msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome back", _customerDTO.getUserName());

            } else {

                bIsLoggedIn = false;
                msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Login credentials invalid!", _customerDTO.getMessage());
            }

            if (bIsLoggedIn) {

                _loggedOnUser = getUserProfile(_customerDTO);

            } else {

                _loggedOnUser = null;
            }

        } catch (Exception ex) {

            bIsLoggedIn = false;

            _loggedOnUser = null;
            _logonCredentials = new LogonCredentials();

            msg = new FacesMessage(FacesMessage.SEVERITY_FATAL, "Error communicating with customer web service!",
                    String.format("Unable to access customer web service at %s: %s",
                            _customerWebService.getWSDLDocumentLocation(),
                            ex.getMessage()));
        }

        if (msg != null)
            FacesContext.getCurrentInstance().addMessage(null, msg);

        ctx.addCallbackParam("loggedIn", bIsLoggedIn);
    }
View Full Code Here

     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void Logout(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        FacesMessage msg = null;
        boolean bIsLoggedOut = false;

        _loggedOnUser = null;
        _logonCredentials = new LogonCredentials();

        bIsLoggedOut = true;

        msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bye",
                "Please come back and check our offerings soon!");

        if (msg != null)
            FacesContext.getCurrentInstance().addMessage(null, msg);

        ctx.addCallbackParam("loggedOut", bIsLoggedOut);
        SystemController.redirectUrl(ctx, "index");
    }
View Full Code Here

     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void CheckCustomerProfile(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();

        if (this.getLoggedOnUser() == null) {

            return;
        }
View Full Code Here

     *
     * @param evt  contains information about the event that triggers the execution of this operation
     */
    public void CancelUpdateProfile(ActionEvent evt) {

        RequestContext ctx = RequestContext.getCurrentInstance();

        this.CheckCustomerProfile(evt);

        SystemController.redirectUrl(ctx, "index");
    }
View Full Code Here

     *
     * @param actEvent contains information about the event that triggers the execution of this operation
     */
    public void UserRegistration(ActionEvent actEvent) {

        RequestContext ctx = RequestContext.getCurrentInstance();
        FacesMessage msg = null;

        boolean bIsRegistered = false;

        try {

            UserProfile profile = getNewUser();

            if (!profile.getChangePin().getNewPin().equals(profile.getChangePin().getRetryPin())) {

                bIsRegistered = false;

                msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatch",
                        "Please make sure that your re-type your pin correctly!");
            } else {

                profile.getProfileData().setPassword(profile.getChangePin().getNewPin());

                CustomerDTO _customerDTO = _customerWebService.getCustomerServiceImplPort().registerCustomer(
                        profile.getProfileData());

                if (_customerDTO.getReturncode() == 0) {

                    bIsRegistered = true;

                    AddressDTO defaultAdr =_customerWebService.getCustomerServiceImplPort().maintainAddress(_customerDTO, profile.getBillingAddress());

                    if (defaultAdr.getReturncode() != 0) {
                   
                        msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Profile Data missing",
                                        "Could not store your billing address. Please check the data!");
                       
                        SystemController.redirectUrl(ctx, "userprofile");
                    }
                   
                    defaultAdr = _customerWebService.getCustomerServiceImplPort().maintainAddress(_customerDTO, profile.getShippingAddress());

                    if (defaultAdr.getReturncode() != 0) {

                        msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Profile Data missing",
                                "Could not store your shipping address. Please check the data!");

                        SystemController.redirectUrl(ctx, "userprofile");
                    }

                    if (msg == null)
                        msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", _customerDTO.getUserName());

                } else {

                    bIsRegistered = false;
                    msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Registration failed!", _customerDTO.getMessage());
                }

                if (bIsRegistered) {

                    _loggedOnUser = getUserProfile(_customerDTO);
                    _newUser = null;

                } else {

                    _loggedOnUser = null;
                }
            }

        } catch (Exception ex) {

            bIsRegistered = false;
            msg = new FacesMessage(FacesMessage.SEVERITY_FATAL, "Error communicating with customer web service!",
                    String.format("Unable to access customer web service at %s: %s",
                            _customerWebService.getWSDLDocumentLocation(),
                            ex.getMessage()));
        }

        if (msg != null)
            FacesContext.getCurrentInstance().addMessage(null, msg);

        ctx.addCallbackParam("registered", bIsRegistered);
    }
View Full Code Here

TOP

Related Classes of org.primefaces.context.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.