Search in sources :

Example 6 with ElementContainer

use of com.revolsys.ui.html.view.ElementContainer in project com.revolsys.open by revolsys.

the class HtmlUiBuilder method newDetailView.

public ElementContainer newDetailView(final Object object, final List<KeySerializer> serializers) {
    final KeySerializerDetailSerializer model = new KeySerializerDetailSerializer(serializers);
    model.setObject(object);
    final DetailView detailView = new DetailView(model, this.typeName);
    return new ElementContainer(detailView);
}
Also used : ElementContainer(com.revolsys.ui.html.view.ElementContainer) TabElementContainer(com.revolsys.ui.html.view.TabElementContainer) KeySerializerDetailSerializer(com.revolsys.ui.html.serializer.KeySerializerDetailSerializer) DetailView(com.revolsys.ui.html.view.DetailView)

Example 7 with ElementContainer

use of com.revolsys.ui.html.view.ElementContainer in project com.revolsys.open by revolsys.

the class HtmlUiBuilder method addTabDataTable.

public void addTabDataTable(final TabElementContainer container, final Object builderName, final String pageName, Map<String, Object> parameters) {
    final HtmlUiBuilder<?> builder = getBuilder(builderName);
    if (builder != null) {
        parameters = new HashMap<>(parameters);
        parameters.put("deferLoading", 0);
        parameters.put("tabbed", true);
        parameters.put("scrollYPercent", 1);
        final HttpServletRequest request = getRequest();
        final ElementContainer element = builder.newDataTable(request, pageName, parameters);
        if (element != null) {
            final String tabId = builder.getTypeName() + "_" + pageName;
            final String title = builder.getPageTitle(pageName);
            container.add(tabId, title, element);
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ElementContainer(com.revolsys.ui.html.view.ElementContainer) TabElementContainer(com.revolsys.ui.html.view.TabElementContainer)

Example 8 with ElementContainer

use of com.revolsys.ui.html.view.ElementContainer in project com.revolsys.open by revolsys.

the class HtmlUiBuilder method newObjectEditPage.

public Element newObjectEditPage(final T object, final String prefix) throws IOException, ServletException {
    if (object == null) {
        throw new PageNotFoundException();
    } else {
        final HttpServletRequest request = HttpServletUtils.getRequest();
        final Set<String> parameterNamesToSave = new HashSet<>();
        parameterNamesToSave.add(getIdParameterName());
        final String pageName = getName(prefix, "edit");
        final Form form = newTableForm(object, pageName);
        for (final String param : parameterNamesToSave) {
            form.addSavedParameter(param, request.getParameter(param));
        }
        form.initialize(request);
        if (form.isPosted() && form.isMainFormTask()) {
            if (form.isValid() && preUpdate(form, object)) {
                updateObject(object);
                postUpdate(object);
                final Map<String, Object> parameters = new HashMap<>();
                // Get after object has changed
                final Object id = Property.get(object, getIdPropertyName());
                parameters.put(getIdParameterName(), id);
                final Page viewPage = getPage(prefix, "view");
                final String url = viewPage.getFullUrl(parameters);
                redirectAfterCommit(url);
                return new TabElementContainer();
            } else {
                setRollbackOnly(object);
            }
        } else {
            setRollbackOnly(object);
        }
        final Page page = getPage(prefix, "edit");
        final String title = page.getExpandedTitle();
        request.setAttribute("title", title);
        final Menu actionMenu = new Menu();
        addMenuItem(actionMenu, prefix, "view", "Cancel", "_top").addProperty("buttonClass", "btn-danger");
        addMenuItem(actionMenu, prefix, "edit", "Revert to Saved", "_top").addProperty("buttonClass", "btn-warning");
        final String name = form.getName();
        final Menu saveItem = new Menu("Save", "javascript:$('#" + name + "').submit()");
        saveItem.addProperty("buttonClass", "btn-primary");
        actionMenu.addMenuItem(saveItem);
        final ButtonsToolbarElement buttonsToolbar = new ButtonsToolbarElement(actionMenu);
        final ElementContainer view = new ElementContainer(form, buttonsToolbar);
        final TabElementContainer tabs = new TabElementContainer();
        tabs.add(title, view);
        return tabs;
    }
}
Also used : ElementContainer(com.revolsys.ui.html.view.ElementContainer) TabElementContainer(com.revolsys.ui.html.view.TabElementContainer) UiBuilderObjectForm(com.revolsys.ui.html.form.UiBuilderObjectForm) HtmlUiBuilderObjectForm(com.revolsys.ui.html.form.HtmlUiBuilderObjectForm) Form(com.revolsys.ui.html.form.Form) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Page(com.revolsys.ui.web.config.Page) TabElementContainer(com.revolsys.ui.html.view.TabElementContainer) HttpServletRequest(javax.servlet.http.HttpServletRequest) PageNotFoundException(com.revolsys.ui.web.exception.PageNotFoundException) Menu(com.revolsys.ui.model.Menu) ButtonsToolbarElement(com.revolsys.ui.html.view.ButtonsToolbarElement) HashSet(java.util.HashSet)

Aggregations

ElementContainer (com.revolsys.ui.html.view.ElementContainer)8 TabElementContainer (com.revolsys.ui.html.view.TabElementContainer)7 Menu (com.revolsys.ui.model.Menu)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 ButtonsToolbarElement (com.revolsys.ui.html.view.ButtonsToolbarElement)3 Page (com.revolsys.ui.web.config.Page)3 Form (com.revolsys.ui.html.form.Form)2 HtmlUiBuilderObjectForm (com.revolsys.ui.html.form.HtmlUiBuilderObjectForm)2 UiBuilderObjectForm (com.revolsys.ui.html.form.UiBuilderObjectForm)2 KeySerializer (com.revolsys.ui.html.serializer.key.KeySerializer)2 PageNotFoundException (com.revolsys.ui.web.exception.PageNotFoundException)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 DefinitionListLayout (com.revolsys.ui.html.layout.DefinitionListLayout)1 UnorderedListLayout (com.revolsys.ui.html.layout.UnorderedListLayout)1 KeySerializerDetailSerializer (com.revolsys.ui.html.serializer.KeySerializerDetailSerializer)1 KeySerializerTableSerializer (com.revolsys.ui.html.serializer.KeySerializerTableSerializer)1 RowsTableSerializer (com.revolsys.ui.html.serializer.RowsTableSerializer)1