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

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


        //
        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);
            String queryString = urlPathHelper.getOriginatingQueryString(request);
            String actionPath = "/widget" + lookupPath + "?" + queryString;
            ServletContext widgetContext = getServletContext();
            if (StringUtils.hasText(widgetConfig.getContext())) {
                widgetContext = getServletContext().getContext(widgetConfig.getContext());
                if (widgetContext == null) {
                    return;
                }
            }
            //
            widgetRequest.setAttribute("requestType", "action");
            widgetRequest.setAttribute("widgetConfig", widgetConfig);
            //
            Navigator navigator = Navigator.reset();
            //
            for (WidgetActionInterceptor actionInterceptor : widgetActionInterceptors) {
                actionInterceptor.beforeAction(request, response);
            }
            widgetContext.getRequestDispatcher(actionPath).forward(widgetRequest, widgetResponse);
            //
            for (WidgetActionInterceptor actionInterceptor : widgetActionInterceptors) {
                actionInterceptor.afterAction(request, response);
            }
            //
            if (!StringUtils.hasText(navigator.getNavigateTo())) {
                widgetResponse.flushBuffer();
                return;
            }
            //
            String pathExpr = widgetConfig.getNavigationMap().get(navigator.getNavigateTo());
            if (StringUtils.hasText(pathExpr)) {
                Expression expression = expressionParser.parseExpression(pathExpr, ParserContext.TEMPLATE_EXPRESSION);
                EvaluationContext evaluationContext = createEvaluationContext();
                String path = (String) expression.getValue(evaluationContext, request);
                //
View Full Code Here


    @Override
    public void setValue(String value_) {
        value_ = "/widget" + value_;
        //
        WidgetConfig widgetConfig = (WidgetConfig) pageContext.getRequest().getAttribute("widgetConfig");
        //
        if (value_.contains("?")) {
            value_ += "&widgetId=" + widgetConfig.getId();
        } else {
            value_ += "?widgetId=" + widgetConfig.getId();
        }
        //
        super.setValue(value_);
    }
View Full Code Here

        if (request instanceof WidgetRequest && response instanceof WidgetResponse) {
            WidgetRequest widgetRequest = (WidgetRequest) request;
            WidgetResponse widgetResponse = (WidgetResponse) response;
            //
            if ("render".equals(widgetRequest.getRequestType())) {
                WidgetConfig widgetConfig = widgetRequest.getWidgetConfig();
                WidgetResponse cachedWidgetResponse = (WidgetResponse) widgetCache.get(widgetConfig);
                if (cachedWidgetResponse != null) {
                    FileCopyUtils.copy(cachedWidgetResponse.getResponseAsByteArray(), widgetResponse.getOutputStream());
                    return false;
                }
View Full Code Here

        if (request instanceof WidgetRequest && response instanceof WidgetResponse) {
            WidgetRequest widgetRequest = (WidgetRequest) request;
            WidgetResponse widgetResponse = (WidgetResponse) response;
            //
            if ("render".equals(widgetRequest.getRequestType())) {
                WidgetConfig widgetConfig = widgetRequest.getWidgetConfig();
                if (widgetConfig.getCache() > 0) {
                    widgetCache.put(widgetConfig, widgetResponse);
                }
            }
        }
    }
View Full Code Here

    }

    private Object getWidgetPrefValue(MethodParameter methodParameter, NativeWebRequest webRequest) {
        WidgetPref widgetPreference = methodParameter.getParameterAnnotation(WidgetPref.class);
        if (widgetPreference != null) {
            WidgetConfig widgetConfig = (WidgetConfig) webRequest.getAttribute("widgetConfig", WebRequest.SCOPE_REQUEST);
            String widgetPreferenceName = getWidgetPreferenceName(methodParameter, widgetPreference);
            if (widgetConfig != null) {
                String defaultValue = widgetPreference.defaultValue();
                Object value = widgetConfig.getPreferences().get(widgetPreferenceName);
                if (StringUtils.hasText(defaultValue) && value == null) {
                    value = defaultValue;
                }
                //
                if (widgetPreference.required()) {
View Full Code Here

                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);
View Full Code Here

TOP

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

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.