本文整理匯總了Java中org.apache.wicket.behavior.Behavior類的典型用法代碼示例。如果您正苦於以下問題:Java Behavior類的具體用法?Java Behavior怎麽用?Java Behavior使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Behavior類屬於org.apache.wicket.behavior包,在下文中一共展示了Behavior類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initLayout
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
private void initLayout() {
final TextField input = initTextField();
input.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//nothing to do, just update model data
}
});
input.add(new Behavior() {
@Override
public void bind(Component component) {
super.bind(component);
component.add(AttributeModifier.replace("onkeydown",
Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
}
});
input.setOutputMarkupId(true);
add(input);
}
示例2: decorate
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
private AbstractDynamicBookmarkableLink decorate(AbstractDynamicBookmarkableLink link) {
if (linkBehaviorIfInvalid != null) {
switch (linkBehaviorIfInvalid) {
case HIDE:
link.hideIfInvalid();
break;
case THROW_EXCEPTION:
link.throwExceptionIfInvalid();
break;
}
}
for (Behavior linkBehavior : linkBehaviors) {
link.add(linkBehavior);
}
return link;
}
示例3: getPanel
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
@Override
public WebMarkupContainer getPanel(final String containerId) {
final Object modelValue = panelModel.getObject();
final Panel panel = PanelFactory.get().getPanel(containerId, modelValue);
final Boolean behaviorAdded = panel.getMetaData(KEY_DISABLED_BEHAVIOR_ADDED);
if (behaviorAdded == null || !behaviorAdded) {
panel.setMetaData(KEY_DISABLED_BEHAVIOR_ADDED, true);
panel.add(new Behavior() {
@Override
public void onConfigure(final Component component) {
super.onConfigure(component);
component.setEnabled(ModelTab.this.isEnabled());
}
});
} else {
throw new IllegalStateException(
"KEY_DISABLED_BEHAVIOR_ADDED not expected, since panels are normally not cached!");
}
return panel;
}
示例4: bind
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
@Override
public void bind(Component component) {
if (getTargetId() == null) {
// If we have a titled border behavior, than place the disabled-addon icon within the border title
for (Behavior b : component.getBehaviors()) {
if (b instanceof TitledBorderBehavior) {
if (!isEnabled()) {
component.remove(b);
}
setTargetId(component.getMarkupId() + "-border-icon");
((TitledBorderBehavior) b).setCssClass("disabled-addon");
}
}
}
super.bind(component);
}
示例5: getScrollBehaviour
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
private Behavior getScrollBehaviour(){
return new AttributeModifier("onscroll", Model.of(this.getMarkupId())){
private static final long serialVersionUID = 3523727356782417598L;
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(OnDomReadyHeaderItem.forScript("InfiniteScroll.getFromContainer('"+getMarkupId()+"').setUrls('"+upBehavior.getCallbackUrl()+"', '"+downBehavior.getCallbackUrl()+"')"));
}
@Override
protected String newValue(String currentValue, String replacementValue) {
return "InfiniteScroll.handleScroll('"+InfiniteScrollListView.this.getMarkupId()+"')";
}
};
}
示例6: testDatepickerInvokeSpecialDates
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
@Test
public void testDatepickerInvokeSpecialDates() {
final List<SpecialDate> list = Arrays.asList(new SpecialDate(christmas, "holiday", "Christmas"));
BootstrapDatepicker picker = new BootstrapDatepicker("picker") {
private static final long serialVersionUID = 1L;
@Override
public Collection<SpecialDate> getSpecialDates() {
return list;
}
};
List<? extends Behavior> behaviors = picker.getBehaviors();
assertEquals(1, behaviors.size());
assertTrue(behaviors.get(0) instanceof BootstrapDatePickerBehaviour);
assertEquals(list, ((BootstrapDatePickerBehaviour)behaviors.get(0)).getSpecialDates());
}
示例7: onInitialize
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
@Override
protected void onInitialize() {
super.onInitialize();
if(pageClass!=null){
AbstractLink link = new BookmarkablePageLink<WebPage>("link", pageClass);
add(link);
}
add(new Behavior() {
@Override
public void onComponentTag(Component component, ComponentTag tag) {
super.onComponentTag(component, tag);
if(isActive()) tag.append("class", "active", " ");
}
});
}
示例8: SynchronizerHelper
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
public SynchronizerHelper(DMDWebGenPageContext context, String wicketId, String propertyName, boolean enableThoughUnmodifiable) {
this.context = context;
this.enableThoughUnmodifiable = enableThoughUnmodifiable;
context.getPage().add(new Behavior() {
private static final long serialVersionUID = 1L;
@Override
public void afterRender(Component component) {
super.afterRender(component);
// domainreference needs to be reset on ajax updates
ref = null;
}
});
this.wicketId = wicketId;
this.propertyName = propertyName;
saveAsPrototype();
}
示例9: makeListView
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
private ListView<ProcessedGradeItem> makeListView(String componentName, List<ProcessedGradeItem> itemList) {
return new ListView<ProcessedGradeItem>(componentName, itemList) {
/**
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
@Override
protected void populateItem(ListItem<ProcessedGradeItem> item) {
item.add(new Label("itemTitle", new PropertyModel<String>(item.getDefaultModel(), "itemTitle")));
PropertyModel<String> commentLabelProp = new PropertyModel<String>(item.getDefaultModel(), "commentLabel");
final String commentLabel = commentLabelProp.getObject();
item.add(new Behavior() {
@Override
public void afterRender(Component component) {
super.afterRender(component);
if(commentLabel != null){
component.getResponse().write(
"<tr class=\"comment\"><td class=\"item_title\"><span>" + commentLabel + "</span></td></tr>"
);
}
}
});
}
};
}
示例10: testInitialization
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
@Test
public void testInitialization() {
TestGroup tg = new TestGroup("test", null);
tg.init("prop", tg, true, String.class, null);
startTest(tg);
replayAll();
verifyAll();
getTester().assertComponent(tg.getPageRelativePath(), TestGroup.class);
getTester().assertComponent(tg.field.getPageRelativePath(), TextField.class);
getTester().assertComponent(tg.box.getPageRelativePath(), WebMarkupContainer.class);
getTester().assertRequired(tg.field.getPageRelativePath());
assertEquals("prop", tg.field.getLabel().getObject());
List<? extends Behavior> behaviors = tg.field.getBehaviors();
assertEquals(1, behaviors.size());
assertTrue(behaviors.get(0) instanceof ValidatorAdapter);
assertTrue(((ValidatorAdapter<?>)behaviors.get(0)).getValidator() instanceof HibernateValidatorProperty);
}
示例11: markLastVisibleChild
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
public static void markLastVisibleChild(WebMarkupContainer container) {
Component lastVisible = null;
for (Component child: container) {
for (Behavior behavior: child.getBehaviors()) {
if (behavior instanceof LastVisibleAppender) {
child.remove(behavior);
}
}
child.configure();
if (child.isVisible())
lastVisible = child;
}
if (lastVisible != null)
lastVisible.add(new LastVisibleAppender("class", "last-visible").setSeparator(" "));
}
示例12: stopRefreshing
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
public void stopRefreshing(Refreshable refreshable, AjaxRequestTarget target) {
Component refreshingBehaviorParent = refreshable.getRefreshingBehaviorParent();
for (Behavior behavior : refreshingBehaviorParent.getBehaviors()) {
if (behavior instanceof RemovableAjaxTimerBehavior) {
((RemovableAjaxTimerBehavior) behavior).remove(target);
}
}
}
示例13: visibleIfFalse
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
public static Behavior visibleIfFalse(final NonEmptyModel<Boolean> model) {
return new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !model.getObject();
}
};
}
示例14: enabledIfFalse
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
public static Behavior enabledIfFalse(final NonEmptyModel<Boolean> model) {
return new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return !model.getObject();
}
};
}
示例15: createTitleToggler
import org.apache.wicket.behavior.Behavior; //導入依賴的package包/類
private void createTitleToggler() {
// title is also a link that toggles expansion state
final AjaxFallbackLink titleLink = new IndicatingAjaxFallbackLink("titleToggle") {
@Override
public void onClick(AjaxRequestTarget target) {
final ExpansionState expansionState = expansionModel.getObject();
if (expansionState == ExpansionState.COLLAPSED) {
expansionModel.setObject(ExpansionState.EXPANDED);
} else {
expansionModel.setObject(ExpansionState.COLLAPSED);
}
if (target != null) {
target.add(ExpandablePanel.this);
}
}
};
// Facet name becomes title
titleLink.add(createTitleLabel("title"));
titleLink.add(new AttributeModifier("aria-controls", ExpandablePanel.this.getMarkupId()));
titleLink.add(new WebMarkupContainer("expand"));
titleLink.add(new WebMarkupContainer("collapse"));
titleLink.add(new Behavior() {
@Override
public void onConfigure(Component component) {
final boolean expanded = expansionModel.getObject().equals(ExpansionState.EXPANDED);
component.get("expand").setVisible(!expanded);
component.get("collapse").setVisible(expanded);
}
});
add(titleLink);
}