Changeset 5135


Ignore:
Timestamp:
05/06/14 07:57:42 (10 years ago)
Author:
Twan Goosen
Message:

turned permalink toggle link into a form and button (to prevent people from bookmarking the wicket action link)

Location:
vlo/trunk/vlo-web-app/src/main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/TopLinksPanel.html

    r5033 r5135  
    2424    <body>
    2525        <wicket:panel>
    26             <wicket:enclosure child="linkrequest">
    27                 <a wicket:id="linkrequest" id="permalink" href="" title="Get a permanent link to this page"><span>Permalink</span></a>
     26            <wicket:enclosure child="linkRequest">
     27                <form id="permalink" wicket:id="linkRequest">
     28                    <input wicket:id="linkRequestButton" type="submit" title="Get a permanent link to this page" value="Permalink" />
     29                </form>
    2830                <input wicket:id="linkfield" type="text" id="permalinkfield"></input>
    2931                |
  • vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/TopLinksPanel.java

    r4987 r5135  
    2323import eu.clarin.cmdi.vlo.service.PageParametersConverter;
    2424import org.apache.solr.common.SolrDocument;
     25import org.apache.wicket.Component;
    2526import org.apache.wicket.Session;
    2627import org.apache.wicket.ajax.AjaxRequestTarget;
     28import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
    2729import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink;
     30import org.apache.wicket.markup.html.form.Form;
    2831import org.apache.wicket.markup.html.form.TextField;
    2932import org.apache.wicket.markup.html.link.ExternalLink;
     
    5558public class TopLinksPanel extends GenericPanel<QueryFacetsSelection> {
    5659
    57     @SpringBean(name="queryParametersConverter")
     60    @SpringBean(name = "queryParametersConverter")
    5861    private PageParametersConverter<QueryFacetsSelection> paramsConverter;
    5962    @SpringBean
     
    8083
    8184        // action to link to request the permalink
    82         add(createPermaLink("linkrequest", linkModel));
     85        add(createPermaLink("linkRequest"));
    8386        // field that holds the actual link
    8487        add(createLinkField("linkfield", linkModel));
     
    99102    }
    100103
    101     private Link<String> createPermaLink(String id, final IModel<String> linkModel) {
    102         return new IndicatingAjaxFallbackLink<String>(id, linkModel) {
     104    private Component createPermaLink(String id) {
     105        // Create a form with a button to toggle permalink rather than an action link
     106        // to prevent people from confusing the link generated by wicket with
     107        // the actual permalink generated by the application
     108        final Form form = new Form(id) {
    103109
    104110            @Override
    105             public void onClick(AjaxRequestTarget target) {
     111            protected void onConfigure() {
     112                super.onConfigure();
     113                setVisible(TopLinksPanel.this.getModel() != null);
     114            }
     115        };
     116
     117        form.add(new AjaxFallbackButton("linkRequestButton", form) {
     118
     119            @Override
     120            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    106121                // toggle
    107122                linkVisibilityModel.setObject(!linkVisibilityModel.getObject());
     
    115130            }
    116131
    117             @Override
    118             protected void onConfigure() {
    119                 super.onConfigure();
    120                 setVisible(TopLinksPanel.this.getModel() != null);
    121             }
     132        });
    122133
    123         };
     134        return form;
    124135    }
    125136
  • vlo/trunk/vlo-web-app/src/main/resources/eu/clarin/cmdi/vlo/wicket/pages/vlo-header.css

    r5033 r5135  
    102102}
    103103
     104form#permalink {
     105    display: inline;
     106}
     107
     108form#permalink input {
     109    /* permalink submit button should look like link to fit in with other links */
     110    display: inline;
     111    border: none;
     112    background: none;
     113    text-decoration: underline;
     114    color: #00f;
     115    font-family: inherit;
     116    font-size: inherit;
     117    padding: 0;
     118    cursor: pointer;
     119}
     120
    104121#permalinkfield
    105122{
Note: See TracChangeset for help on using the changeset viewer.