org.wicketstuff.jwicket.ui.effect.Transfer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwicket-ui-effects Show documentation
Show all versions of jwicket-ui-effects Show documentation
WicketJQuery by Stefan Lindner has been renamed to jWicket, mavenized, and migrated
to WicketStuff. This Wicketstuff version supercedes the original version which was available
at http://subversion.visionet.de/project/WicketJQuery/wiki
package org.wicketstuff.jwicket.ui.effect;
import org.apache.wicket.Component;
import org.wicketstuff.jwicket.JQueryJavascriptResourceReference;
public class Transfer extends AbstractJqueryUiEffect {
private static final long serialVersionUID = 1L;
public Transfer() {
super(new JQueryJavascriptResourceReference(Transfer.class, "jquery.effects.transfer.min.js"));
}
@Override
String getEffectName() {
return "transfer";
}
private String className = null;
/** Set the CSS class name
*
* @param value the CSS class name
* @return this object
*/
public Transfer setClassName(final String value) {
this.className = value;
return this;
}
private String to = null;
/** Set the jQuery selector of the component to transform to
*
* @param value the jQuery selector
* @return this object
*/
public Transfer setTo(final String value) {
this.to = "jQuery('#" + value + "')";
return this;
}
public Transfer setTo(final Component component) throws Exception{
if (!component.getOutputMarkupId())
throw new IllegalArgumentException("You must not transform to a component that has not set output markup id: " + component);
this.to = "jQuery('#" + component.getMarkupId() + "')";
return this;
}
@Override
void appendOptions(final StringBuilder jsString) {
if (className != null || to != null) {
boolean firstOption = true;
jsString.append(",{");
if (className != null) {
jsString.append("className:'");
jsString.append(className);
jsString.append("'");
firstOption = false;
}
if (to != null) {
if (!firstOption)
jsString.append(",");
jsString.append("to:");
jsString.append(to);
}
jsString.append("}");
}
}
}