Examples of FacesContext


Examples of javax.faces.context.FacesContext

    public String open() {
       
        if (!isLoggedIn())
            return redirect();
       
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebObjects objects = (DcWebObjects) vr.resolveVariable(fc, "webObjects");
        List<?> data = (List<?>) objects.getData().getRowData();
       
        DcWebObject wod = (DcWebObject) vr.resolveVariable(fc, "webObject");
        int moduleIdx = objects.getModule();

        if (!getUser().isAuthorized(DcModules.get(moduleIdx)))
            return redirect();

        wod.initialize(moduleIdx);
        wod.setRowIdx(objects.getData().getRowIndex());
        wod.setID((String) data.get(data.size() - 1));
        wod.setName(wod.getDcObject().toString());
        wod.load();
       
        DcObject dco = wod.getDcObject();
        String filename = dco.getFilename();
        File file = new File(filename);
        HttpServletResponse response = (HttpServletResponse) fc.getExternalContext().getResponse();

        int read = 0;
        byte[] bytes = new byte[1024];
        response.setContentType("application/data");
        response.setHeader("Content-Disposition", "attachment;filename=\"" + file.getName() + "\"");
View Full Code Here

Examples of javax.faces.context.FacesContext

        loadImages();
        return getReturnTarget();
    }
   
    public String load() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebImages images = (DcWebImages) vr.resolveVariable(fc, "images");

        Map map = fc.getExternalContext().getRequestParameterMap();
        images.setCurrent(Integer.valueOf((String) map.get("fieldIdx")));
       
        return getReturnTarget();
    }
View Full Code Here

Examples of javax.faces.context.FacesContext

       
        return getReturnTarget();
    }
   
    protected DcObject getItem() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebObjects objects = (DcWebObjects) vr.resolveVariable(fc, "webObjects");
        List<?> data = (List) objects.getData().getRowData();
       
        int moduleIdx = objects.getModule();
        return DataManager.getItem(moduleIdx, (String) data.get(data.size() - 1));
View Full Code Here

Examples of javax.faces.context.FacesContext

    }
   
    private void loadImages() {
        DcObject dco = getItem();

        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebImages images = (DcWebImages) vr.resolveVariable(fc, "images");
        images.clear();
       
        for (DcField field : dco.getFields()) {
            if (field.getFieldType() == ComponentFactory._PICTUREFIELD) {
View Full Code Here

Examples of javax.faces.context.FacesContext

            if (!wf.isMultiRelate())
                dco.setValue(wf.getIndex(), wf.getValue());
        }
       
        if (wo.isChild()) {
            FacesContext fc = FacesContext.getCurrentInstance();
            VariableResolver vr = fc.getApplication().getVariableResolver();
            DcWebObject wod = (DcWebObject) vr.resolveVariable(fc, "webObject");
            dco.setValue( dco.getParentReferenceFieldIndex(), wod.getID());
        }
       
        try {
         
          dco.setUpdateGUI(false);
         
            if (wo.isNew()) {
                dco.setIDs();
                dco.saveNew(false);
            } else {
                dco.saveUpdate(false);
            }
           
        } catch (ValidationException ve) {
            FacesContext fc = FacesContext.getCurrentInstance();
            fc.addMessage("saveError", new FacesMessage(ve.getMessage()));
            return current();
        }
       
        if (wo.isNew()) {
            wo.initialize(wo.getModule());
View Full Code Here

Examples of javax.faces.context.FacesContext

            return afterUpdated();
        }
    }
   
    protected boolean isValid(DcWebObject wo) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Collection<DcWebField> fields = new ArrayList<DcWebField>();
        fields.addAll(wo.getFields());
        fields.addAll(wo.getTechnicalFields());
       
        boolean valid = true;
        int msg = 0;
        for (DcField field :  DcModules.get(wo.getModule()).getFields()) {
            for (DcWebField wf : fields) {
               
                if (wf.getIndex() == field.getIndex()) {
                   
                    if (Utilities.isEmpty(wf.getValue()) && field.isRequired()) {
                        valid = false;
                        fc.addMessage("msg" + msg++, new FacesMessage("Required field " + field.getLabel() + " has not been filled."));
                        continue;

                    } else if (!Utilities.isEmpty(wf.getValue()) &&
                               (field.getValueType() == DcRepository.ValueTypes._BIGINTEGER ||
                                field.getValueType() == DcRepository.ValueTypes._LONG)) {
                        try {
                            Long.valueOf(String.valueOf(wf.getValue()));
                        } catch (NumberFormatException nfe) {
                            valid = false;
                            fc.addMessage("msg" + msg++, new FacesMessage(field.getLabel() + " should contain a numeric value."));
                            continue;
                        }
                    }
                }
            }
View Full Code Here

Examples of javax.faces.context.FacesContext

import net.datacrow.core.security.SecurityException;

public class Security {

    public String login() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
       
        try {
            SecuredUser su = SecurityCentre.getInstance().login(wu.getUsername(), wu.getPassword(), true);
            wu.setSecuredUser(su);
            DcWebModules modules = (DcWebModules) vr.resolveVariable(fc, "modules");
            modules.load();
        } catch (SecurityException se) {
            fc.addMessage("loginError", new FacesMessage(se.getMessage()));
            return "login";
        }
       
        return "search";
    }
View Full Code Here

Examples of javax.faces.context.FacesContext

    public String getUsername() {
        return getUser() != null ? getUser().getUser().toString() : "";
    }
   
    public SecuredUser getUser() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
        return wu != null ? wu.getSecuredUser() : null;
    }
View Full Code Here

Examples of javax.faces.context.FacesContext

        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
        return wu != null ? wu.getSecuredUser() : null;
    }
   
    public boolean isLoggedIn() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
        return wu != null && SecurityCentre.getInstance().isLoggedIn(wu.getSecuredUser());
    }
View Full Code Here

Examples of javax.faces.context.FacesContext

        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
        return wu != null && SecurityCentre.getInstance().isLoggedIn(wu.getSecuredUser());
    }
   
    public String logoff() {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        DcWebUser wu = (DcWebUser) vr.resolveVariable(fc, "user");
       
        wu.setPassword(null);
        wu.setUsername(null);
        wu.setSecuredUser(null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.