All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wicketstuff.twitter.intents.AbstractIntentLink Maven / Gradle / Ivy

There is a newer version: 10.3.0
Show newest version
package org.wicketstuff.twitter.intents;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;

/**
 * 
 * @author Till Freier
 * 
 */
public abstract class AbstractIntentLink extends WebMarkupContainer
{
	private IModel intentUrl;

	public AbstractIntentLink(final String id, final String url)
	{
		super(id);

		intentUrl = Model.of(url);

		add(new AttributeModifier("href", new AbstractReadOnlyModel()
		{
			@Override
			public String getObject()
			{
				return getUrl();
			}
		}));
	}


	protected abstract PageParameters getParameters();

	public String getUrl()
	{
		final PageParametersEncoder encoder = new PageParametersEncoder();
		final Url url = encoder.encodePageParameters(getParameters());

		final StringBuilder sb = new StringBuilder();
		sb.append(intentUrl.getObject());
		sb.append(url.toString());

		return sb.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy