Search in sources :

Example 6 with RequestMapping

use of com.revolsys.ui.web.annotation.RequestMapping in project com.revolsys.open by revolsys.

the class DefaultAnnotationHandlerMapping method validateHandler.

/**
 * Validate the given annotated handler against the current request.
 * @see #validateMapping
 */
@Override
protected void validateHandler(final Object handler, final HttpServletRequest request) throws Exception {
    RequestMapping mapping = this.cachedMappings.get(handler.getClass());
    if (mapping == null) {
        mapping = AnnotationUtils.findAnnotation(handler.getClass(), RequestMapping.class);
    }
    if (mapping != null) {
        validateMapping(mapping, request);
    }
    request.setAttribute(USE_DEFAULT_SUFFIX_PATTERN, this.useDefaultSuffixPattern);
}
Also used : RequestMapping(com.revolsys.ui.web.annotation.RequestMapping)

Example 7 with RequestMapping

use of com.revolsys.ui.web.annotation.RequestMapping in project com.revolsys.open by revolsys.

the class HtmlUiBuilder method initPages.

protected void initPages() {
    final Class<?> clazz = getClass();
    final Method[] methods = clazz.getMethods();
    for (final Method method : methods) {
        final String name = method.getName();
        final RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
        if (requestMapping != null) {
            String pageName = requestMapping.name();
            if (Property.isEmpty(pageName)) {
                pageName = name;
            }
            String title = requestMapping.title();
            if (Property.isEmpty(title)) {
                title = CaseConverter.toCapitalizedWords(pageName);
            }
            final boolean secure = requestMapping.secure();
            String path = null;
            final String[] paths = requestMapping.value();
            if (paths.length > 0) {
                path = paths[0];
            }
            final String[] fieldNames = requestMapping.fieldNames();
            if (fieldNames.length > 0) {
                newView(pageName, Arrays.asList(fieldNames));
                newKeyList(pageName, Arrays.asList(fieldNames));
                final ColumnSortOrder[] columnSortOrder = requestMapping.columnSortOrder();
                final List<List<Object>> tableSortOrder = new ArrayList<>();
                for (final ColumnSortOrder sortOrder : columnSortOrder) {
                    int fieldIndex = -1;
                    final String sortFieldName = sortOrder.value();
                    for (int i = 0; i < fieldNames.length; i++) {
                        final String fieldName = fieldNames[i];
                        if (sortFieldName.equals(fieldName)) {
                            fieldIndex = i;
                        }
                    }
                    final boolean ascending = sortOrder.ascending();
                    String direction;
                    if (ascending) {
                        direction = "asc";
                    } else {
                        direction = "desc";
                    }
                    tableSortOrder.add(Arrays.asList(fieldIndex, direction));
                }
                if (!tableSortOrder.isEmpty()) {
                    setListSortOrder(pageName, tableSortOrder);
                }
            }
            final String permission = requestMapping.permission();
            final Page page = new Page(pageName, title, path, secure);
            page.setPermission(permission);
            addPage(page);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Page(com.revolsys.ui.web.config.Page) Method(java.lang.reflect.Method) ColumnSortOrder(com.revolsys.ui.web.annotation.ColumnSortOrder) RequestMapping(com.revolsys.ui.web.annotation.RequestMapping) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

RequestMapping (com.revolsys.ui.web.annotation.RequestMapping)7 Navbar (com.revolsys.ui.model.Navbar)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 MenuElement (com.revolsys.ui.html.view.MenuElement)1 Menu (com.revolsys.ui.model.Menu)1 ColumnSortOrder (com.revolsys.ui.web.annotation.ColumnSortOrder)1 Page (com.revolsys.ui.web.config.Page)1 OutputStream (java.io.OutputStream)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Controller (org.springframework.stereotype.Controller)1 HttpRequestMethodNotSupportedException (org.springframework.web.HttpRequestMethodNotSupportedException)1 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)1 NoSuchRequestHandlingMethodException (org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException)1