Example usage for org.apache.wicket.request.mapper.parameter PageParameters add

List of usage examples for org.apache.wicket.request.mapper.parameter PageParameters add

Introduction

In this page you can find the example usage for org.apache.wicket.request.mapper.parameter PageParameters add.

Prototype

public PageParameters add(final String name, final Object value) 

Source Link

Document

Adds a page parameter to these with name and value

Usage

From source file:almira.sample.web.SearchForm.java

License:Apache License

@Override
public final void onSubmit() {
    PageParameters params = new PageParameters();
    if (searchString != null) {
        params.add("searchString", searchString);
    }/*from  www .  j  av a 2 s .  c  om*/
    setResponsePage(ListCatapultsPage.class, params);
}

From source file:almira.sample.web.WicketListCatapultsPageTest.java

License:Apache License

@Test
public void pageRendersWithoutErrors() throws ParseException {
    context.checking(new Expectations() {
        {//from w  ww  .  ja v  a 2  s  . c  o  m
            atLeast(1).of(queryService).searchByName(CATAPULT_NAME, 0, 1);
            will(returnValue(resultList));

            atLeast(1).of(queryService).countByName(CATAPULT_NAME);
            will(returnValue(1));

            atLeast(1).of(queryService).load(1L);
            will(returnValue(catapult));
        }
    });

    PageParameters params = new PageParameters();
    params.add("searchString", CATAPULT_NAME);
    startPage(ListCatapultsPage.class, params);
    assertRenderedPage(ListCatapultsPage.class);
    assertNoErrorMessage();
}

From source file:almira.sample.web.WicketShowCatapultPageTest.java

License:Apache License

@Test
public void catapultNameIsDiplayed() {
    context.checking(new Expectations() {
        {/*from w w  w.  j  ava 2  s  .co  m*/
            atLeast(1).of(loadService).load(1L);
            will(returnValue(catapult));
        }
    });
    PageParameters params = new PageParameters();
    params.add("catapultId", "1");
    startPage(ShowCatapultPage.class, params);
    assertRenderedPage(ShowCatapultPage.class);
    assertNoErrorMessage();
    assertLabel("name", CATAPULT_NAME);
}

From source file:br.com.ieptbto.cra.security.UserRoleAuthorizationStrategy.java

License:Open Source License

@Override
public boolean isActionAuthorized(Component component, Action action) {
    for (IAuthorizationStrategy strategy : strategies) {
        if (strategy.isActionAuthorized(component, action) == false) {

            // Essa parte do codigo foi alterada para sempre redirecionar
            // para pagina de login quando nao for autorizado.

            // return true (codigo original)

            ISecureApplication app = (ISecureApplication) Application.get();
            PageParameters parameters = new PageParameters();
            parameters.add("error", ErroValidacao.SEM_PERMISSAO_DE_ACESSO_A_PAGINA.getMensagemErro());
            throw new RestartResponseAtInterceptPageException(app.getHomePage(), parameters);

        }//w ww . j  a  v a 2s .c o  m
    }
    return true;
}

From source file:ch.tkuhn.nanobrowser.AgentItem.java

License:Open Source License

public AgentItem(String id, AgentElement a, int guiItemStyle) {
    super(id);/*  ww  w. j  a v a 2 s  . c o m*/

    PageParameters params = new PageParameters();
    params.add("uri", a.getURI());
    BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("agentlink", AgentPage.class,
            params);
    add(link);

    WebMarkupContainer icon = new WebMarkupContainer("icon");
    if (a.isBot()) {
        icon.add(new AttributeModifier("src", new Model<String>("icons/bot.svg")));
    }
    link.add(icon);

    Label nameLabel = new Label("agent", a.getName());
    nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM);
    link.add(nameLabel);
}

From source file:ch.tkuhn.nanobrowser.MenuBar.java

License:Open Source License

public MenuBar(String id) {
    super(id);/*from w w  w  .j  a v a  2s.com*/

    BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("publish", PublishPage.class);
    add(link);

    PageParameters params = new PageParameters();
    params.add("uri", NanobrowserSession.get().getUser().getURI());
    BookmarkablePageLink<WebPage> userLink = new BookmarkablePageLink<WebPage>("userlink", AgentPage.class,
            params);
    add(userLink);

    userLink.add(new Label("user", NanobrowserSession.get().getUser().getName()));

    searchTextField = new TextField<String>("searchtextfield", Model.of(""));

    Form<?> searchForm = new Form<Void>("searchform") {

        private static final long serialVersionUID = 4204397843169014882L;

        protected void onSubmit() {
            String s = searchTextField.getModelObject();
            if (s == null)
                s = "";
            PageParameters params = new PageParameters();
            params.add("q", s);
            setResponsePage(SearchPage.class, params);
        }

    };

    add(searchForm);
    searchForm.add(searchTextField);
}

From source file:ch.tkuhn.nanobrowser.NanopubItem.java

License:Open Source License

public NanopubItem(String id, NanopubElement n, int guiItemStyle) {
    super(id);//  w w w.j  av a2s  . c  o m

    PageParameters params = new PageParameters();
    params.add("uri", n.getURI());
    BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("nanopublink", NanopubPage.class,
            params);
    add(link);
    WebMarkupContainer icon = new WebMarkupContainer("icon");
    if (n.isValid()) {
        icon.add(new AttributeModifier("src", new Model<String>("icons/nanopubv.svg")));
    }
    link.add(icon);

    String date = n.getCreateDateString();
    Label dateLabel;
    if (date == null) {
        dateLabel = new Label("nanopubdate", "");
    } else {
        dateLabel = new Label("nanopubdate", n.getCreateDateString());
    }
    dateLabel.setVisible(guiItemStyle == ThingElement.LONG_GUI_ITEM);
    add(dateLabel);
    Label nameLabel = new Label("nanopubname", " " + n.getShortName() + " ");
    nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM);
    link.add(nameLabel);
}

From source file:ch.tkuhn.nanobrowser.PaperItem.java

License:Open Source License

public PaperItem(String id, PaperElement p, int guiItemStyle) {
    super(id);/*from   w ww. j  ava2 s.  com*/

    PageParameters params = new PageParameters();
    params.add("uri", p.getURI());
    BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("doilink", PaperPage.class, params);
    add(link);

    Label nameLabel = new Label("doi", p.getDoiString());
    nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM);
    link.add(nameLabel);
}

From source file:ch.tkuhn.nanobrowser.PublishPage.java

License:Open Source License

public PublishPage(final PageParameters parameters) {

    add(new MenuBar("menubar"));

    Form<?> form = new Form<Void>("form") {

        private static final long serialVersionUID = -6839390607867733448L;

        protected void onSubmit() {
            sentenceError.setObject("");
            doiError.setObject("");
            String s = sentenceField.getModelObject();
            SentenceElement sentence = null;
            if (s != null && SentenceElement.isSentenceURI(s)) {
                sentence = new SentenceElement(s);
            } else {
                try {
                    sentence = SentenceElement.withText(s);
                } catch (AidaException ex) {
                    sentenceError.setObject("ERROR: " + ex.getMessage());
                    return;
                }/*from w  w  w.  j  av a 2s.  c  o m*/
            }
            String d = doiField.getModelObject();
            PaperElement paper = null;
            if (d != null && !d.isEmpty()) {
                try {
                    paper = PaperElement.forDoi(d);
                } catch (IllegalArgumentException ex) {
                    doiError.setObject("ERROR: Invalid DOI");
                    return;
                }
            }
            String prov = "";
            if (paper != null) {
                prov = ": swan:citesAsSupportiveEvidence <" + paper.getURI() + "> .";
            }
            URI nanopubUri = sentence.publish(getUser(), exampleNanopubCheckbox.getModel().getObject(), prov);
            PageParameters params = new PageParameters();
            params.add("uri", nanopubUri.stringValue());
            MainPage.addToList(new NanopubElement(nanopubUri.stringValue()));
            MainPage.addToList(getUser());
            MainPage.addToList(sentence);
            setResponsePage(NanopubPage.class, params);
        }

    };

    add(form);

    form.add(new Label("author", NanobrowserSession.get().getUser().getName()));
    form.add(exampleNanopubCheckbox = new CheckBox("examplenanopub", new Model<>(false)));
    form.add(sentenceField = new TextField<String>("sentence", Model.of("")));
    sentenceError = Model.of("");
    form.add(new Label("sentenceerror", sentenceError));
    form.add(doiField = new TextField<String>("doi", Model.of("")));
    doiError = Model.of("");
    form.add(new Label("doierror", doiError));

}

From source file:ch.tkuhn.nanobrowser.SentenceItem.java

License:Open Source License

public SentenceItem(String id, SentenceElement s, int guiItemStyle) {
    super(id);/*from   w ww.  j av  a  2 s  .  c  o  m*/

    PageParameters params = new PageParameters();
    params.add("uri", s.getURI());
    BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("sentencelink", SentencePage.class,
            params);
    add(link);

    Label nameLabel = new Label("sentence", s.getSentenceText());
    nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM);
    link.add(nameLabel);
}