Package org.focusns.common.web.page.config

Examples of org.focusns.common.web.page.config.PageConfig


    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //
        NativeWebRequest webRequest = new ServletWebRequest(request);
        //
        if (WebUtils.isIncludeRequest(request)) {
            PageConfig pageConfig = (PageConfig) request.getAttribute("pageConfig");
            if (pageConfig!=null) {
                //
                for(AnnotationConstraint annotationConstraint : annotationConstraints) {
                    if(annotationConstraint.support(handler)) {
                        if(annotationConstraint.canHandle(webRequest, handler)==false) {
View Full Code Here


            }
            //
            Map<String, WidgetRequest> widgetRequestMap = new HashMap<String, WidgetRequest>();
            Map<String, WidgetResponse> widgetResponseMap = new HashMap<String, WidgetResponse>();
            //
            PageConfig pageConfig = (PageConfig) request.getAttribute("pageConfig");
            //
            for (PageRenderInterceptor pageRenderInterceptor : pageRenderInterceptors) {
                if(pageRenderInterceptor.beforeRender(request, response)==false){
                    return ;
                }
            }
            //
            for (String position : pageConfig.getPositionConfigMap().keySet()) {
                PositionConfig positionConfig = pageConfig.getPositionConfigMap().get(position);
                for (WidgetConfig widgetConfig : positionConfig.getWidgetConfigMap().values()) {
                    //
                    WidgetRequest widgetRequest = new WidgetRequest(request, widgetConfig, "render");
                    WidgetResponse widgetResponse = new WidgetResponse(response);
                    //
View Full Code Here

    public void doAction(HttpServletRequest request, HttpServletResponse response) throws PageEngineException {
        //
        try {
            //
            PageConfig pageConfig = (PageConfig) request.getSession().getAttribute("pageConfig");
            String widgetId = (String) request.getAttribute("widgetId");
            WidgetConfig widgetConfig = pageConfig.getWidgetConfigById(widgetId);
            //
            WidgetRequest widgetRequest = new WidgetRequest(request, widgetConfig, "action");
            WidgetResponse widgetResponse = new WidgetResponse(response);
            //
            String lookupPath = urlPathHelper.getLookupPathForRequest(request);
View Full Code Here

public class PageSecurityInterceptor implements PageRenderInterceptor {

    @Override
    public boolean beforeRender(HttpServletRequest request, HttpServletResponse response) {
        //
        PageConfig pageConfig = (PageConfig) request.getAttribute("pageConfig");
        String authority = pageConfig.getAuthority();
        if(StringUtils.hasText(authority)) {
            authority = StringUtils.replace(authority, "-", ":");
            WebSubject webSubject = (WebSubject) SecurityUtils.getSubject();
            return webSubject.isPermitted(authority);
        }
View Full Code Here

            //
            PageFilterRequest pageFilterRequest = new PageFilterRequest(request);
            PageFilterResponse pageFilterResponse = new PageFilterResponse(response);
            pageFilterRequest.parseMatrixParameters();
            //
            PageConfig pageConfig = pageFactory.find(lookupPath, pageFilterRequest.getParameterMap());
            if (pageConfig != null) {
                // parse matrix parameters
                pageFilterRequest.setAttribute("pageConfig", pageConfig);
                pageFilterRequest.getSession().setAttribute("pageConfig", pageConfig);
                pageEngine.doRender(pageFilterRequest, pageFilterResponse);
                //
                if(response.isCommitted()) {
                    return ;
                }
                String layout = !StringUtils.hasText(pageConfig.getLayout()) ? defaultLayout : pageConfig.getLayout();
                request.getRequestDispatcher(layout).forward(pageFilterRequest, pageFilterResponse);
                //
                return;
            }
            //
View Full Code Here

            Element pagesEle = xmlDoc.getDocumentElement();
            List<Element> pageEles = DomUtils.getChildElementsByTagName(pagesEle, "page");
            for (Element pageEle : pageEles) {
                String abstractAttr = pageEle.getAttribute("abstract");
                if (StringUtils.hasText(abstractAttr)) {
                    PageConfig pageConfig = parsePageConfigFile(pageEle);
                    abstractPageConfigMap.put(abstractAttr, pageConfig);
                }
            }
        }
        // parse pages
        for (Resource resource : resources) {
            Document xmlDoc = xmlParser.parseAndValidate(resource);
            Element pagesEle = xmlDoc.getDocumentElement();
            List<Element> pageEles = DomUtils.getChildElementsByTagName(pagesEle, "page");
            for (Element pageEle : pageEles) {
                String abstractAttr = pageEle.getAttribute("abstract");
                if (!StringUtils.hasText(abstractAttr)) {
                    PageConfig pageConfig = parsePageConfigFile(pageEle);
                    pageConfigList.add(pageConfig);
                }
            }
        }
        // merges pages
        List<PageConfig> mergedPageConfigList = new ArrayList<PageConfig>();
        for (PageConfig pageConfig : pageConfigList) {
            String extendsTarget = pageConfig.getParameters().get("extends");
            if (StringUtils.hasText(extendsTarget)) {
                PageConfig abstractPageConfig = abstractPageConfigMap.get(extendsTarget);
                //
                PageConfig newPageConfig = new PageConfig(pageConfig.getPath(), pageConfig.getLayout());
                newPageConfig.setAuthority(pageConfig.getAuthority());
                newPageConfig.setParameters(pageConfig.getParameters());
                // add widget from abstract page
                for (String position : abstractPageConfig.getPositionConfigMap().keySet()) {
                    PositionConfig abstractPositionConfig = abstractPageConfig.getPositionConfigMap().get(position);
                    newPageConfig.addPositionConfig(abstractPositionConfig);
                }
                // add widget from extends page
                for (String position : pageConfig.getPositionConfigMap().keySet()) {
                    PositionConfig positionConfig = pageConfig.getPositionConfigMap().get(position);
                    newPageConfig.addPositionConfig(positionConfig);
                }
                //
                mergedPageConfigList.add(newPageConfig);
            } else {
                mergedPageConfigList.add(pageConfig);
View Full Code Here

        String path = pageEle.getAttribute("path");
        String layout = pageEle.getAttribute("layout");
        String authority = pageEle.getAttribute("authority");
        Map<String, String> parameters = getParameters(pageEle);
        //
        PageConfig pageConfig = new PageConfig(path, layout);
        pageConfig.setAuthority(authority);
        pageConfig.setParameters(parameters);
        List<Element> positionEles = DomUtils.getChildElementsByTagName(pageEle, "position");
        for (Element positionEle : positionEles) {
            //
            String position = positionEle.getAttribute("name");
            PositionConfig positionConfig = new PositionConfig(pageConfig);
            positionConfig.setName(position);
            List<Element> widgetEles = DomUtils.getChildElementsByTagName(positionEle, "widget");
            for (Element widgetEle : widgetEles) {
                //
                String styleId = widgetEle.getAttribute("styleId");
                String styleClass = widgetEle.getAttribute("styleClass");
                //
                String context = widgetEle.getAttribute("context");
                String target = widgetEle.getAttribute("target");
                String mode = widgetEle.getAttribute("mode");
                String cache = widgetEle.getAttribute("cache");
                String order = widgetEle.getAttribute("order");
                //
                WidgetConfig widgetConfig = new WidgetConfig(positionConfig);
                widgetConfig.setStyleId(styleId);
                widgetConfig.setStyleClass(styleClass);
                widgetConfig.setContext(context);
                widgetConfig.setTarget(target);
                widgetConfig.setMode(mode);
                widgetConfig.setCache("".equals(cache) ? 0 : Integer.parseInt(cache));
                widgetConfig.setOrder("".equals(order) ? 0 : Integer.parseInt(order));
                // preference element
                Element preferenceEle = DomUtils.getChildElementByTagName(widgetEle, "preference");
                if (preferenceEle != null) {
                    for (Element prefEle : DomUtils.getChildElements(preferenceEle)) {
                        String name = prefEle.getAttribute("name");
                        String value = DomUtils.getTextValue(prefEle);
                        widgetConfig.getPreferences().put(name, value);
                    }
                }
                // navigation
                Element navigationEle = DomUtils.getChildElementByTagName(widgetEle, "navigation");
                if (navigationEle != null) {
                    Map<String, String> navigationMap = new HashMap<String, String>();
                    List<Element> eventEles = DomUtils.getChildElementsByTagName(navigationEle, "event");
                    for (Element eventEle : eventEles) {
                        String eventOn = eventEle.getAttribute("on");
                        String eventTo = DomUtils.getTextValue(eventEle);
                        navigationMap.put(eventOn, eventTo);
                    }
                    widgetConfig.setNavigationMap(navigationMap);
                }
                // validation
                Element validationEle = DomUtils.getChildElementByTagName(widgetEle, "validation");
                if (validationEle != null) {
                    widgetConfig.setValidationForm(validationEle.getAttribute("formId"));
                    Element targetEle = DomUtils.getChildElementByTagName(validationEle, "target");
                    if (targetEle != null) {
                        widgetConfig.setValidationTarget(DomUtils.getTextValue(targetEle).trim());
                    }
                    Element groupsEle = DomUtils.getChildElementByTagName(validationEle, "groups");
                    if (groupsEle != null) {
                        List<String> validationGroups = new ArrayList<String>();
                        List<Element> groupEles = DomUtils.getChildElementsByTagName(groupsEle, "group");
                        for (Element groupEle : groupEles) {
                            validationGroups.add(DomUtils.getTextValue(groupEle).trim());
                        }
                        widgetConfig.setValidationGroups(validationGroups);
                    }
                }
                //
                positionConfig.addWidgetConfig(widgetConfig);
                // pageConfig.addWidgetConfig(position, widgetConfig);
            }
            pageConfig.addPositionConfig(positionConfig);
        }
        //
        return pageConfig;
    }
View Full Code Here

TOP

Related Classes of org.focusns.common.web.page.config.PageConfig

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.