Example usage for org.apache.wicket.util.value ValueMap ValueMap

List of usage examples for org.apache.wicket.util.value ValueMap ValueMap

Introduction

In this page you can find the example usage for org.apache.wicket.util.value ValueMap ValueMap.

Prototype

public ValueMap() 

Source Link

Document

Constructs empty ValueMap.

Usage

From source file:com.cloudera.recordbreaker.fisheye.SettingsPage.java

License:Open Source License

public SettingsPage() {
    FishEye fe = FishEye.getInstance();//  w  ww  .  ja v a 2 s  .com
    AccessController accessCtrl = fe.getAccessController();
    final String username = accessCtrl.getCurrentUser();
    final ValueMap logins = new ValueMap();
    logins.put("currentuser", username);
    this.setOutputMarkupPlaceholderTag(true);

    //
    // Login/logout
    //
    add(new LoginForm("loginform", logins));
    add(new LogoutForm("logoutform", logins));
    final Label loginErrorLabel = new Label("loginErrorMessage", "Your username and password did not match.");
    loginErrorMsgDisplay.add(loginErrorLabel);
    loginErrorMsgDisplay.setOutputMarkupPlaceholderTag(true);
    add(loginErrorMsgDisplay);
    loginErrorMsgDisplay.setVisibilityAllowed(false);

    //
    // Add filesystem/remove filesystem
    //
    final ValueMap fsinfo = new ValueMap();
    add(new FilesystemRegistrationForm("fsaddform", fsinfo));
    add(new FilesystemInfoForm("fsinfoform", fsinfo));
    final Label fsErrorLabel = new Label("fsErrorMessage", "The filesystem was not found.");
    fsErrorMsgDisplay.add(fsErrorLabel);
    fsErrorMsgDisplay.setOutputMarkupPlaceholderTag(true);
    add(fsErrorMsgDisplay);
    fsErrorMsgDisplay.setVisibilityAllowed(false);

    //
    // Hive query server info
    //
    add(new QueryServerInfoForm("queryserverinfo", new ValueMap()));

    //
    // If the filesystem is there, we need to have info about its crawls
    //
    /**
    WebMarkupContainer crawlContainer = new WebMarkupContainer("crawlContainer");
    ListView<CrawlSummary> crawlListView = new ListView<CrawlSummary>("crawlListView", crawlList) {
      protected void populateItem(ListItem<CrawlSummary> item) {
        CrawlSummary cs = item.getModelObject();
        // Fields are: 'crawlid' and 'crawllastexamined'
        item.add(new Label("crawlid", "" + cs.getCrawlId()));
        item.add(new Label("crawllastexamined", cs.getLastExamined()));
      }
    };
    crawlContainer.add(crawlListView);
    fsDisplayContainer.add(crawlContainer);
    crawlContainer.setVisibilityAllowed(crawlList.size() > 0);
    **/

    //
    // Standard environment variables
    //
    add(new Label("fisheyeStarttime", fe.getStartTime().toString()));
    add(new Label("fisheyePort", "" + fe.getPort()));
    try {
        add(new Label("fisheyeDir", "" + fe.getFisheyeDir().getCanonicalPath()));
    } catch (IOException iex) {
        add(new Label("fisheyeDir", "unknown"));
    }
}

From source file:com.pennychecker.wicketexample.mvp.view.EditUserView.java

License:Apache License

public EditUserView() {
    super(VIEW_ID);
    labelTitle = new Label(ID_LABEL_TITLE, "Edit user");
    add(labelTitle);//ww  w  .ja v a  2  s  .co  m
    compundedPropertyModel = new CompoundPropertyModel<ValueMap>(new ValueMap());
    form = new Form<ValueMap>(ID_FORM, compundedPropertyModel) {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit() {
            hideErrorMessages();
            presenter.save_action();
        }

    };
    add(form);

    labelFormFirstname = new Label(ID_FORM_LABEL_FIRSTNAME, "Firstname");
    form.add(labelFormFirstname);

    labelFormLastname = new Label(ID_FORM_LABEL_LASTNAME, "Lastname");
    form.add(labelFormLastname);

    labelFormBirth = new Label(ID_FORM_LABEL_BIRTH, "Birth yyyy/mm/dd");
    form.add(labelFormBirth);

    labelFormErrorBirth = new Label(ID_FORM_LABEL_ERROR_BIRTH);
    form.add(labelFormErrorBirth);

    labelFormErrorFirstname = new Label(ID_FORM_LABEL_ERROR_FIRSTNAME);
    form.add(labelFormErrorFirstname);

    labelFormErrorLastname = new Label(ID_FORM_LABEL_ERROR_LASTNAME);
    form.add(labelFormErrorLastname);

    hideErrorMessages();

    form.add(new TextField<String>(ID_FORM_TEXTFIELD_FIRSTNAME).setType(String.class));

    form.add(new TextField<String>(ID_FORM_TEXTFIELD_LASTNAME).setType(String.class));

    form.add(new TextField<String>(ID_FORM_TEXTFIELD_BIRTH).setType(String.class));

    formCancelLink = new Link<String>(ID_FORM_BUTTON_CANCEL) {

        /**
         * 
         */
        private static final long serialVersionUID = -632482484843710146L;

        @Override
        public void onClick() {
            presenter.cancel_action();
        }

    };
    add(formCancelLink);
}

From source file:com.servoy.j2db.server.headlessclient.WebClientsApplication.java

License:Open Source License

/**
 * @see wicket.protocol.http.WebApplication#init()
 *//*ww w . j ava 2 s  . co  m*/
@Override
protected void init() {
    if (ApplicationServerRegistry.get() == null)
        return; // TODO this is a workaround to allow mobile test client that only starts Tomcat not to give exceptions (please remove if mobile test client initialises a full app. server in the future)

    getResourceSettings().setResourceWatcher(new ServoyModificationWatcher(Duration.seconds(5)));
    //      getResourceSettings().setResourcePollFrequency(Duration.seconds(5));
    getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);
    getResourceSettings().setDefaultCacheDuration((int) Duration.days(365).seconds());
    getMarkupSettings().setCompressWhitespace(true);
    getMarkupSettings().setMarkupCache(new ServoyMarkupCache(this));
    // getMarkupSettings().setStripWicketTags(true);
    getResourceSettings().setResourceStreamLocator(new ServoyResourceStreamLocator(this));
    getResourceSettings().setPackageResourceGuard(new ServoyPackageResourceGuard());
    // getResourceSettings().setResourceFinder(createResourceFinder());
    getResourceSettings().setThrowExceptionOnMissingResource(false);
    getApplicationSettings().setPageExpiredErrorPage(ServoyExpiredPage.class);
    getApplicationSettings().setClassResolver(new ServoyClassResolver());
    getSessionSettings().setMaxPageMaps(15);
    //      getRequestCycleSettings().setGatherExtendedBrowserInfo(true);

    getSecuritySettings().setCryptFactory(new CachingKeyInSessionSunJceCryptFactory());

    Settings settings = Settings.getInstance();
    getDebugSettings().setOutputComponentPath(
            Utils.getAsBoolean(settings.getProperty("servoy.webclient.debug.wicketpath", "false"))); //$NON-NLS-1$ //$NON-NLS-2$
    if (Utils.getAsBoolean(settings.getProperty("servoy.webclient.nice.urls", "false"))) //$NON-NLS-1$ //$NON-NLS-2$
    {
        mount(new HybridUrlCodingStrategy("/solutions", SolutionLoader.class)); //$NON-NLS-1$
        mount(new HybridUrlCodingStrategy("/application", MainPage.class)); //$NON-NLS-1$
        mount(new HybridUrlCodingStrategy("/ss", SolutionLoader.class) //$NON-NLS-1$
        {
            /**
             * @see wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy#matches(wicket.IRequestTarget)
             */
            @Override
            public boolean matches(IRequestTarget requestTarget) {
                return false;
            }
        });
    } else {
        mountBookmarkablePage("/solutions", SolutionLoader.class); //$NON-NLS-1$
        mount(new BookmarkablePageRequestTargetUrlCodingStrategy("/ss", SolutionLoader.class, null) //$NON-NLS-1$
        {
            /**
             * @see wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy#matches(wicket.IRequestTarget)
             */
            @Override
            public boolean matches(IRequestTarget requestTarget) {
                return false;
            }
        });
    }

    long maxSize = Utils.getAsLong(settings.getProperty("servoy.webclient.maxuploadsize", "0"), false); //$NON-NLS-1$ //$NON-NLS-2$
    if (maxSize > 0) {
        getApplicationSettings().setDefaultMaximumUploadSize(Bytes.kilobytes(maxSize));
    }

    getSharedResources().putClassAlias(IApplication.class, "application"); //$NON-NLS-1$
    getSharedResources().putClassAlias(PageContributor.class, "pc"); //$NON-NLS-1$
    getSharedResources().putClassAlias(MaskBehavior.class, "mask"); //$NON-NLS-1$
    getSharedResources().putClassAlias(Application.class, "servoy"); //$NON-NLS-1$
    getSharedResources().putClassAlias(org.wicketstuff.calendar.markup.html.form.DatePicker.class,
            "datepicker"); //$NON-NLS-1$
    getSharedResources().putClassAlias(YUILoader.class, "yui"); //$NON-NLS-1$
    getSharedResources().putClassAlias(JQueryLoader.class, "jquery"); //$NON-NLS-1$
    getSharedResources().putClassAlias(TinyMCELoader.class, "tinymce"); //$NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.markup.html.WicketEventReference.class, "wicketevent"); //$NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.ajax.WicketAjaxReference.class, "wicketajax"); //$NON-NLS-1$
    getSharedResources().putClassAlias(MainPage.class, "servoyjs"); //$NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow.class,
            "modalwindow"); //$NON-NLS-1$

    PackageResource.bind(this, IApplication.class, "images/open_project.gif"); //$NON-NLS-1$
    PackageResource.bind(this, IApplication.class, "images/save.gif"); //$NON-NLS-1$

    mountSharedResource("/formcss", "servoy/formcss"); //$NON-NLS-1$//$NON-NLS-2$

    sharedMediaResource = new SharedMediaResource();
    getSharedResources().add("media", sharedMediaResource); //$NON-NLS-1$

    mount(new SharedResourceRequestTargetUrlCodingStrategy("mediafolder", "servoy/media") //$NON-NLS-1$ //$NON-NLS-2$
    {
        @Override
        protected void appendParameters(AppendingStringBuffer url, Map<String, ?> parameters) {
            if (parameters != null && parameters.size() > 0) {
                Object solutionName = parameters.get("s"); //$NON-NLS-1$
                if (solutionName != null)
                    appendPathParameter(url, null, solutionName.toString());
                Object resourceId = parameters.get("id"); //$NON-NLS-1$
                if (resourceId != null)
                    appendPathParameter(url, null, resourceId.toString());

                StringBuilder queryParams = new StringBuilder();
                for (Entry<?, ?> entry1 : parameters.entrySet()) {
                    Object value = ((Entry<?, ?>) entry1).getValue();
                    if (value != null) {
                        Object key = ((Entry<?, ?>) entry1).getKey();
                        if (!"s".equals(key) && !"id".equals(key)) //$NON-NLS-1$ //$NON-NLS-2$
                        {
                            if (value instanceof String[]) {
                                String[] values = (String[]) value;
                                for (String value1 : values) {
                                    if (queryParams.length() > 0)
                                        queryParams.append("&"); //$NON-NLS-1$
                                    queryParams.append(key).append("=").append(value1);//$NON-NLS-1$
                                }
                            } else {
                                if (queryParams.length() > 0)
                                    queryParams.append("&"); //$NON-NLS-1$
                                queryParams.append(key).append("=").append(value);//$NON-NLS-1$
                            }
                        }
                    }
                }
                if (queryParams.length() > 0) {
                    url.append("?").append(queryParams);//$NON-NLS-1$
                }
            }
        }

        @Override
        protected void appendPathParameter(AppendingStringBuffer url, String key, String value) {
            String escapedValue = value;
            String[] values = escapedValue.split("/");//$NON-NLS-1$
            if (values.length > 1) {
                StringBuilder sb = new StringBuilder(escapedValue.length());
                for (String str : values) {
                    sb.append(urlEncodePathComponent(str));
                    sb.append('/');
                }
                sb.setLength(sb.length() - 1);
                escapedValue = sb.toString();
            } else {
                escapedValue = urlEncodePathComponent(escapedValue);
            }

            if (!Strings.isEmpty(escapedValue)) {
                if (!url.endsWith("/"))//$NON-NLS-1$
                {
                    url.append("/");//$NON-NLS-1$
                }
                if (key != null)
                    url.append(urlEncodePathComponent(key)).append("/");//$NON-NLS-1$
                url.append(escapedValue);
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @see org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy#decodeParameters(java.lang.String, java.util.Map)
         */
        @Override
        protected ValueMap decodeParameters(String urlFragment, Map<String, ?> urlParameters) {
            ValueMap map = new ValueMap();
            final String[] pairs = urlFragment.split("/"); //$NON-NLS-1$
            if (pairs.length > 1) {
                map.add("s", pairs[1]); //$NON-NLS-1$
                StringBuffer sb = new StringBuffer();
                for (int i = 2; i < pairs.length; i++) {
                    sb.append(pairs[i]);
                    sb.append("/"); //$NON-NLS-1$
                }
                sb.setLength(sb.length() - 1);
                map.add("id", sb.toString()); //$NON-NLS-1$
            }
            if (urlParameters != null) {
                map.putAll(urlParameters);
            }
            return map;
        }
    });

    getSharedResources().add("resources", new ServeResources()); //$NON-NLS-1$

    getSharedResources().add("formcss", new FormCssResource(this)); //$NON-NLS-1$

    if (settings.getProperty("servoy.webclient.error.page", null) != null) //$NON-NLS-1$
    {
        getApplicationSettings().setInternalErrorPage(ServoyErrorPage.class);
    }
    if (settings.getProperty("servoy.webclient.pageexpired.page", null) != null) //$NON-NLS-1$
    {
        getApplicationSettings().setPageExpiredErrorPage(ServoyPageExpiredPage.class);
    }

    addPreComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() {
        public void onBeforeRender(Component component) {
            if (component instanceof IServoyAwareBean) {
                IModel model = component.getInnermostModel();
                WebForm webForm = component.findParent(WebForm.class);
                if (model instanceof RecordItemModel && webForm != null) {
                    IRecord record = (IRecord) ((RecordItemModel) model).getObject();
                    FormScope fs = webForm.getController().getFormScope();

                    if (record != null && fs != null) {
                        ((IServoyAwareBean) component).setSelectedRecord(new ServoyBeanState(record, fs));
                    }
                }
            } else {
                if (!component.isEnabled()) {
                    boolean hasOnRender = (component instanceof IFieldComponent
                            && ((IFieldComponent) component)
                                    .getScriptObject() instanceof ISupportOnRenderCallback
                            && ((ISupportOnRenderCallback) ((IFieldComponent) component).getScriptObject())
                                    .getRenderEventExecutor().hasRenderCallback());
                    if (!hasOnRender) {
                        // onrender may change the enable state
                        return;
                    }
                }
                Component targetComponent = null;
                boolean hasFocus = false, hasBlur = false;
                if (component instanceof IFieldComponent
                        && ((IFieldComponent) component).getEventExecutor() != null) {
                    targetComponent = component;
                    if (component instanceof WebBaseSelectBox) {
                        Component[] cs = ((WebBaseSelectBox) component).getFocusChildren();
                        if (cs != null && cs.length == 1)
                            targetComponent = cs[0];
                    }
                    if (component instanceof WebDataHtmlArea)
                        hasFocus = true;

                    // always install a focus handler when in a table view to detect change of selectedIndex and test for record validation
                    if (((IFieldComponent) component).getEventExecutor().hasEnterCmds()
                            || component.findParent(WebCellBasedView.class) != null
                            || (((IFieldComponent) component)
                                    .getScriptObject() instanceof ISupportOnRenderCallback
                                    && ((ISupportOnRenderCallback) ((IFieldComponent) component)
                                            .getScriptObject()).getRenderEventExecutor().hasRenderCallback())) {
                        hasFocus = true;
                    }
                    // Always trigger event on focus lost:
                    // 1) check for new selected index, record validation may have failed preventing a index changed
                    // 2) prevent focus gained to be called when field validation failed
                    // 3) general ondata change
                    hasBlur = true;
                } else if (component instanceof WebBaseLabel) {
                    targetComponent = component;
                    hasFocus = true;
                }

                if (targetComponent != null) {
                    MainPage mainPage = targetComponent.findParent(MainPage.class);
                    if (mainPage.isUsingAjax()) {
                        AbstractAjaxBehavior eventCallback = mainPage.getPageContributor().getEventCallback();
                        if (eventCallback != null) {
                            String callback = eventCallback.getCallbackUrl().toString();
                            if (component instanceof WebDataRadioChoice
                                    || component instanceof WebDataCheckBoxChoice
                                    || component instanceof WebDataLookupField
                                    || component instanceof WebDataComboBox
                                    || component instanceof WebDataListBox
                                    || component instanceof WebDataHtmlArea) {
                                // is updated via ServoyChoiceComponentUpdatingBehavior or ServoyFormComponentUpdatingBehavior, this is just for events
                                callback += "&nopostdata=true";
                            }
                            for (IBehavior behavior : targetComponent.getBehaviors()) {
                                if (behavior instanceof EventCallbackModifier) {
                                    targetComponent.remove(behavior);
                                }
                            }
                            if (hasFocus) {
                                StringBuilder js = new StringBuilder();
                                js.append("eventCallback(this,'focus','").append(callback).append("',event)"); //$NON-NLS-1$ //$NON-NLS-2$
                                targetComponent.add(new EventCallbackModifier("onfocus", true, //$NON-NLS-1$
                                        new Model<String>(js.toString())));
                                targetComponent.add(new EventCallbackModifier("onmousedown", true, //$NON-NLS-1$
                                        new Model<String>("focusMousedownCallback(event)"))); //$NON-NLS-1$
                            }
                            if (hasBlur) {
                                boolean blockRequest = false;
                                // if component has ondatachange, check for blockrequest
                                if (component instanceof ISupportEventExecutor
                                        && ((ISupportEventExecutor) component).getEventExecutor()
                                                .hasChangeCmd()) {
                                    WebClientSession webClientSession = WebClientSession.get();
                                    blockRequest = webClientSession != null && webClientSession.blockRequest();
                                }

                                StringBuilder js = new StringBuilder();
                                js.append("postEventCallback(this,'blur','").append(callback) //$NON-NLS-1$
                                        .append("',event," + blockRequest + ")"); //$NON-NLS-1$
                                targetComponent.add(new EventCallbackModifier("onblur", true, //$NON-NLS-1$
                                        new Model<String>(js.toString())));
                            }
                        }
                    }
                }
            }
        }
    });
}

From source file:com.socialsite.image.ImagePanel.java

License:Open Source License

/**
 * //w w  w .ja v  a2  s.c  om
 * @param component
 *            component id
 * @param id
 *            id used to fetch the image
 * @param imageType
 *            type of the image (userimage , courseimage etc)
 * @param thumb
 *            will show thumb image if true
 * @param lastModified
 *            lastmodified date of the image
 */
public ImagePanel(final String component, final long id, final ImageType imageType, final Date lastModified,
        final boolean thumb, final boolean changeLink) {
    super(component);

    this.changeLink = changeLink;

    // allow the modal window to update the panel
    setOutputMarkupId(true);
    final ResourceReference imageResource = new ResourceReference(imageType.name());
    final Image userImage;
    final ValueMap valueMap = new ValueMap();
    valueMap.add("id", id + "");

    // the version is used to change the url dynamically if the image is
    // changed. This will allow the browser to cache images
    // reference http://code.google.com/speed/page-speed/docs/caching.html
    // #Use fingerprinting to dynamically enable caching.
    valueMap.add("version", lastModified.getTime() + "");
    if (thumb) {
        valueMap.add("thumb", "true");
    }
    add(userImage = new Image("userimage", imageResource, valueMap));
    userImage.setOutputMarkupId(true);

    final ModalWindow modal;
    add(modal = new ModalWindow("modal"));

    modal.setContent(new UploadPanel(modal.getContentId()) {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public String onFileUploaded(final FileUpload upload) {

            if (upload == null || upload.getSize() == 0) {
                // No image was provided
                error("Please upload an image.");
            } else if (!checkContentType(upload.getContentType())) {
                error("Only images of types png, jpg, and gif are allowed.");
            } else {
                saveImage(upload.getBytes());
            }

            return null;
        }

        @Override
        public void onUploadFinished(final AjaxRequestTarget target, final String filename,
                final String newFileUrl) {

            final ResourceReference imageResource = new ResourceReference(imageType.name());

            final ValueMap valueMap = new ValueMap();
            valueMap.add("id", id + "");
            // change the image lively
            valueMap.add("version", new Date().getTime() + "");
            if (thumb) {
                valueMap.add("thumb", "true");
            }

            userImage.setImageResourceReference(imageResource, valueMap);
            // update the image after the user changes it
            target.addComponent(userImage);
        }
    });
    modal.setTitle(" Select the image ");
    modal.setCookieName("modal");

    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public boolean onCloseButtonClicked(final AjaxRequestTarget target) {
            return true;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void onClose(final AjaxRequestTarget target) {
        }
    });

    add(new AjaxLink<Void>("changeimage") {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (changeLink) {
                // TODO allow admins to change the university image and
                // allow
                // staffs to change the course image
                // it. don't show it for thumb images
                return hasRole(SocialSiteRoles.OWNER) || hasRole(SocialSiteRoles.STAFF);
            }
            return false;

        }

        @Override
        public void onClick(final AjaxRequestTarget target) {
            modal.show(target);
        }
    });
}

From source file:de.voolk.marbles.web.pages.admin.auth.ListUserPage.java

License:Open Source License

@SuppressWarnings("serial")
public ListUserPage() {
    action = new WebComponent("action");
    add(action);//ww  w .  j av a  2 s  . com
    add(new DataView<User>("userList", new UserDataProvider(authentificationService)) {
        @SuppressWarnings("rawtypes")
        private Link removeLink;

        @Override
        @SuppressWarnings("rawtypes")
        protected void populateItem(Item<User> userItem) {
            final User user = userItem.getModelObject();
            removeLink = new Link("remove") {
                @Override
                public void onClick() {
                    selectedUsertoRemove = user;
                    ValueMap info = new ValueMap();
                    info.put("user", user.getName());
                    new ReplacingConfirmationActionPanel(action, new StringResourceModel("remove.confirmation",
                            ListUserPage.this, new Model<ValueMap>(info))) {
                        @Override
                        public void execute() {
                            pageService.removeAllPages(user);
                            authentificationService.removeUser(user.getId());
                            setResponsePage(ListUserPage.this.getClass());
                        }

                        @Override
                        public void cancel() {
                            super.cancel();
                            selectedUsertoRemove = null;
                        }
                    };
                }
            };
            String crossPic = "cross.png";
            if (authentificationService.userHasRole(user, IdentSession.SYSTEM_ROLE)
                    || selectedUsertoRemove != null) {
                removeLink.setEnabled(false);
                crossPic = "cross_gray.png";
            }
            removeLink.add(new Image("crossImg", new ResourceReference(ListUserPage.class, crossPic)));
            userItem.add(removeLink);
            userItem.add(new Label("id", String.valueOf(user.getId())));
            userItem.add(new Label("name", user.getName()));
            userItem.add(new Label("email", user.getEmail()));
        }
    });
}

From source file:info.jtrac.web.RestMultiActionController.java

License:Apache License

public void itemSearchGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String queryString = request.getQueryString();
    logger.debug("parsing queryString: " + queryString);
    ValueMap map = new ValueMap();
    RequestUtils.decodeParameters(queryString, map);
    logger.debug("decoded: " + map);
    User user = (User) request.getAttribute("user");
    PageParameters params = new PageParameters(map);
    ItemSearch itemSearch = ItemListPage.getItemSearch(jtrac, user, params);
    initXmlResponse(response);/* www. java  2 s  .c  om*/
    jtrac.writeAsXml(itemSearch, response.getWriter());
}

From source file:net.kornr.swit.button.ButtonResource.java

License:Apache License

/**
 * Return a ValueMap to associate to a ButtonResource ResourceReference.
 * This methods registers the pair [template, text] if it it not already in the normal cache.
 * @param template//from w w w  . j  a v  a 2s  . c  om
 * @param text
 * @return
 */
static public ValueMap getValueMap(ButtonTemplate template, String text) {
    Long id = getUniqueId(new ButtonResourceKey(template, text));
    ValueMap map = new ValueMap();
    map.put("id", id.toString());
    return map;
}

From source file:net.kornr.swit.button.ButtonResource.java

License:Apache License

/**
 * Return a ValueMap for a pair [template, text]. The pair is stored in the temporary cache.
 * //  ww w .java  2s  .  c o m
 * @param template the ButtonTemplate object to use
 * @param text the text of the button
 * @param download true if the resource should be sent to the browser as an attachment, false (the default) to send it normally as an inline image. 
 * @param filename if download is true, this specified the filename under which the button image should be sent to the web browser. Can be null, for a default value.
 * @return A ValueMap to use with a ButtonResource ResourceReference 
 */
static public ValueMap getTemporaryValueMap(ButtonTemplate template, String text, boolean download,
        String filename) {
    Long id = getTemporaryId(new ButtonResourceKey(template, text));
    ValueMap map = new ValueMap();
    map.put("id", id.toString());
    if (download)
        map.put("download", "please");
    if (download && filename != null)
        map.put("filename", filename);
    return map;
}

From source file:net.kornr.swit.wicket.border.graphics.BorderMaker.java

License:Apache License

public static org.apache.wicket.markup.html.image.Image getImage(String id, Long imageId, String type,
        boolean indexed) {
    ValueMap args = new ValueMap();
    args.put("border", type);
    args.put("id", imageId.toString());
    args.put("type", indexed ? "indexed" : "rgb");
    ResourceReference ref = getReference();
    org.apache.wicket.markup.html.image.Image img = new org.apache.wicket.markup.html.image.Image(id, ref,
            args);/* w  w w.  j  a v a 2 s.c o m*/

    Dimension dim = BorderMaker.get(imageId).getMapSize(type);

    img.add(new AttributeModifier("width", true, new Model<String>("" + dim.width)));
    img.add(new AttributeModifier("height", true, new Model<String>("" + dim.height)));
    return img;
}

From source file:net.kornr.swit.wicket.border.graphics.BorderMaker.java

License:Apache License

public static String getUrl(Long imageId, String type, boolean indexed) {
    ValueMap args = new ValueMap();
    args.put("border", type);
    args.put("id", imageId.toString());
    args.put("type", indexed ? "indexed" : "rgb");
    ResourceReference ref = getReference();
    return RequestCycle.get().urlFor(ref, args).toString();
}