List of usage examples for org.apache.wicket.ajax AjaxRequestTarget addChildren
void addChildren(MarkupContainer parent, Class<?> childCriteria);
childCriteria
From source file:org.artifactory.webapp.wicket.page.security.acl.PermissionTargetCreateUpdatePanel.java
License:Open Source License
private void onCheckboxUpdate(FormComponent checkbox, AjaxRequestTarget target) { final MarkupContainer row = checkbox.findParent(OddEvenItem.class); target.addChildren(row, StyledCheckbox.class); }
From source file:org.brixcms.plugin.site.page.admin.VariablesPanel.java
License:Apache License
public VariablesPanel(String id, IModel<BrixNode> model) { super(id, model); List<IGridColumn<IDataSource<BrixNode>, BrixNode>> columns = new ArrayList<IGridColumn<IDataSource<BrixNode>, BrixNode>>(); columns.add(new CheckBoxColumn<IDataSource<BrixNode>, BrixNode>("checkbox")); columns.add(new PropertyColumn<IDataSource<BrixNode>, BrixNode, String>(new ResourceModel("key"), "key")); columns.add(new EditablePropertyColumn<IDataSource<BrixNode>, BrixNode, String>(new ResourceModel("value"), "value") { @Override/*from www . j av a2s . c o m*/ protected void addValidators(FormComponent component) { component.setRequired(true); } }); columns.add( new SubmitCancelColumn<IDataSource<BrixNode>, BrixNode>("submitcancel", new ResourceModel("edit")) { @Override protected void onError(AjaxRequestTarget target, IModel rowModel, WebMarkupContainer rowComponent) { target.addChildren(VariablesPanel.this, FeedbackPanel.class); } @Override protected void onSubmitted(AjaxRequestTarget target, IModel<BrixNode> rowModel, WebMarkupContainer rowComponent) { target.addChildren(VariablesPanel.this, FeedbackPanel.class); super.onSubmitted(target, rowModel, rowComponent); } }); final DataGrid<BrixNode> grid = new DefaultDataGrid<BrixNode>("grid", new Model(new DataSource()), columns) { @Override public void onItemSelectionChanged(IModel<BrixNode> item, boolean newValue) { AjaxRequestTarget target = AjaxRequestTarget.get(); if (target != null) { target.addComponent(delete); } super.onItemSelectionChanged(item, newValue); } }; add(grid); grid.setSelectToEdit(false); grid.setClickRowToSelect(true); grid.setContentHeight(17, SizeUnit.EM); add(delete = new AjaxLink<Void>("deleteSelected") { @Override public void onClick(AjaxRequestTarget target) { AbstractContainer node = (AbstractContainer) VariablesPanel.this.getModelObject(); for (IModel<?> m : grid.getSelectedItems()) { Entry e = (Entry) m.getObject(); node.setVariableValue(e.getKey(), null); } node.save(); grid.markAllItemsDirty(); grid.update(); grid.resetSelectedItems(); target.addComponent(this); } @Override public boolean isEnabled() { return grid.getSelectedItems().isEmpty() == false; } }); delete.setOutputMarkupId(true); add(new InsertForm("form") { @Override protected void onItemAdded() { grid.markAllItemsDirty(); grid.update(); } }); add(new FeedbackPanel("feedback").setOutputMarkupId(true)); }
From source file:org.cast.cwm.tag.component.TagList.java
License:Open Source License
public TagList(String id, final PersistedObject target, final User student) { super(id);//from www .ja v a2 s.c o m this.setOutputMarkupId(true); this.target = target; this.user = student == null ? CwmSession.get().getUser() : student; RefreshingView<Tag> list = new RefreshingView<Tag>("tag") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override protected Iterator getItemModels() { allUserTags = TagService.get().tagsForUser(user); List<Tag> tags = new ArrayList<Tag>(allUserTags); for (Tagging ting : TagService.get().taggingsForTarget(user, target)) { tags.remove(ting.getTag()); } return new ModelIteratorAdapter<Tag>(tags.iterator()) { @Override protected IModel<Tag> model(Tag object) { return new CompoundPropertyModel(object); } }; } @Override protected void populateItem(Item<Tag> item) { final Tag t = item.getModelObject(); AjaxLink<Void> link = new AjaxLink<Void>("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget ajaxtarget) { TagService.get().findTaggingCreate(user, target, t.getName()); ajaxtarget.add(TagList.this); ajaxtarget.addChildren(findParent(TagPanel.class), TaggingsListPanel.class); } }; link.setEnabled(student == null); item.add(link); link.add(new TagLabel("name", t)); } }; add(list); }
From source file:org.cast.isi.component.MoveStudentPeriodForm.java
License:Open Source License
public MoveStudentPeriodForm(String id) { super(id);//from w ww .j ava 2 s .co m add(new Label("lastName", new Model<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (getDefaultModelObject() == null) return ""; else { return user.getLastName(); } } })); add(new Label("firstName", new Model<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (getDefaultModelObject() == null) return ""; else { return user.getFirstName(); } } })); add(new Label("currentPeriod", new PropertyModel<String>(ISISession.get().getCurrentPeriodModel(), "name"))); periodChoiceMove = new PeriodChoice("newPeriod", ISISession.get().getCurrentPeriodModel()); add(periodChoiceMove); FeedbackPanel f = new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(this)); add(f); AjaxSubmitLink moveLink = new AjaxSubmitLink("moveLink") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { findParent(ManageClasses.class).visitChildren(EditDisableLink.class, EditDisableLink.getVisitor(target, true)); target.addChildren(getPage(), PeriodStudentSelectPanel.class); target.add(findParent(ManageClasses.class).get("editStudentForm")); // target.add(MoveStudentPeriodForm.this.manageClasses.getEditStudentForm()); target.add(getPeriodTitleContainer()); target.appendJavaScript("$('#moveModal').hide();"); } }; add(moveLink); }
From source file:org.cast.isi.panel.RatePanel.java
License:Open Source License
/** * @param affectText - name of the affect button *//* w w w .j a va 2s. c om*/ private void addAffectButton(final String affectText) { AjaxLink<Void> link = new AjaxLink<Void>(affectText) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { if (readOnly) return false; // The currently selected affect button is disabled return (!affectText.equals(RatePanel.this.getDefaultModelObjectAsString())); } @SuppressWarnings("unchecked") @Override public void onClick(AjaxRequestTarget target) { responseService.saveTextResponse(((IModel<Response>) RatePanel.this.getDefaultModel()), affectText, contentLoc.getLocation()); target.addChildren(RatePanel.this, AjaxLink.class); } @Override protected void onComponentTag(ComponentTag tag) { // if this is the selected button then set the class info for display purposes String tagAttribute = null; if (RatePanel.this.getDefaultModelObject() != null && affectText.equals(((Response) RatePanel.this.getDefaultModelObject()).getText())) { tagAttribute = tag.getAttribute("class"); tag.put("class", tagAttribute + " selected"); } super.onComponentTag(tag); } }; add(link); link.setOutputMarkupId(true); }
From source file:org.cast.isi.panel.ResponseFeedbackButtonPanel.java
License:Open Source License
public ResponseFeedbackButtonPanel(String id, final IModel<Prompt> mPrompt, ResponseFeedbackPanel p) { super(id);/*from ww w .j a v a 2 s .co m*/ this.mPrompt = mPrompt; this.responseFeedbackPanel = p; this.role = ISISession.get().getUser().getRole(); setOutputMarkupPlaceholderTag(true); messageList = getMessageList(); unreadStudentMessages = getUnreadStudentMessages(); unreadTeacherMessages = getUnreadTeacherMessages(); AjaxFallbackLink<Void> link = new AjaxFallbackLink<Void>("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { responseFeedbackPanel.setPromptModel(mPrompt); if (role.subsumes(Role.RESEARCHER)) { // Don't trigger any database changes if researcher clicks button. } else if (role.equals(Role.STUDENT) && !unreadTeacherMessages.isEmpty()) { for (FeedbackMessage m : unreadTeacherMessages) { m.setUnread(false); ISIResponseService.get().updateFeedbackMessage(new HibernateObjectModel<FeedbackMessage>(m), getPage()); } sectionService.adjustMessageCount(ISISession.get().getUser(), ((ISIStandardPage) getPage()).getLoc(), Role.TEACHER, -1 * unreadTeacherMessages.size()); unreadTeacherMessages.clear(); } else if (!role.equals(Role.STUDENT) && !unreadStudentMessages.isEmpty()) { for (FeedbackMessage m : unreadStudentMessages) { m.setUnread(false); ISIResponseService.get().updateFeedbackMessage(new HibernateObjectModel<FeedbackMessage>(m), getPage()); } sectionService.adjustMessageCount(ISISession.get().getStudent(), ((ISIStandardPage) getPage()).getLoc(), Role.STUDENT, -1 * unreadStudentMessages.size()); unreadStudentMessages.clear(); } responseFeedbackPanel.clearFeedbackMessageForm(); responseFeedbackPanel.setCallingButton(ResponseFeedbackButtonPanel.this); eventService.saveEvent("messagepanel:view", mPrompt.getObject().toString(), ((ISIStandardPage) getPage()).getPageName()); if (target != null) { target.add(responseFeedbackPanel); target.add(this); target.appendJavaScript(responseFeedbackPanel.getSidebarDialog().getOpenString()); target.addChildren(getPage(), IDisplayFeedbackStatus.class); } } }; link.add(new AttributeModifier("href", ResponseFeedbackPanel.getDivName())); button = new Icon("button", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (role.equals(Role.STUDENT)) if (unreadTeacherMessages.isEmpty()) return "img/icons/teacher_comments.png"; else return "img/icons/teacher_comments_new.png"; else if (messageList.isEmpty()) return "img/icons/give_feedback.png"; else if (!unreadStudentMessages.isEmpty()) return "img/icons/new_feedback_from_student.png"; else return "img/icons/view_feedback.png"; } }); link.add(new AttributeModifier("title", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (role.equals(Role.STUDENT)) if (unreadTeacherMessages.isEmpty()) return (new ResourceModel("feedback.buttonTitle.viewTComments").getObject()); else return (new ResourceModel("feedback.buttonTitle.newTComments").getObject()); else if (messageList.isEmpty()) return (new ResourceModel("feedback.buttonTitle.giveFeedback").getObject()); else if (!unreadStudentMessages.isEmpty()) return (new ResourceModel("feedback.buttonTitle.viewNewFeedback").getObject()); else return (new ResourceModel("feedback.buttonTitle.viewFeedback").getObject()); } })); button.setOutputMarkupPlaceholderTag(true); link.add(button); // add the correct text for the button link.add(new Label("buttonText", new StringResourceModel("feedback.buttonText.${userRole}.${state}", this, Model.of(this), "default"))); add(link); if (messageList.isEmpty() && role != Role.TEACHER) link.setVisible(false); }
From source file:org.cast.isi.panel.ThumbPanel.java
License:Open Source License
/** * Add one button for each type of thumb name * @param buttonName/* w w w. ja va2s.c o m*/ */ protected void addButton(final String buttonName) { AjaxLink<Void> link = new AjaxLink<Void>(buttonName) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { if (readOnly) return false; // The currently selected rating is disabled return (!buttonName.equals(ThumbPanel.this.getDefaultModelObjectAsString())); } @SuppressWarnings("unchecked") @Override public void onClick(AjaxRequestTarget target) { ISIResponseService.get().saveTextResponse(((IModel<Response>) ThumbPanel.this.getDefaultModel()), buttonName, contentLoc.getLocation()); target.addChildren(ThumbPanel.this, AjaxLink.class); } @Override protected void onComponentTag(ComponentTag tag) { // if the current button is selected, set the class info for the background color String tagAttribute = null; if (ThumbPanel.this.getDefaultModelObject() != null && buttonName .equals(((Response) ThumbPanel.this.getDefaultModel().getObject()).getText())) { tagAttribute = tag.getAttribute("class"); tag.put("class", tagAttribute + " current"); } super.onComponentTag(tag); } }; add(link); link.setOutputMarkupId(true); }
From source file:org.efaps.ui.wicket.components.connection.SessionTablePanel.java
License:Apache License
/** * @param _wicketId wicket for this component * @param _pageReference Reference to the calling page * @param _dataProvider provider for the task table * @throws EFapsException on error//from ww w. j av a 2s. c o m */ public SessionTablePanel(final String _wicketId, final PageReference _pageReference, final SessionProvider _dataProvider) throws EFapsException { super(_wicketId); this.dataProvider = _dataProvider; final List<IColumn<UIUserSession, String>> columns = new ArrayList<>(); columns.add(new AbstractColumn<UIUserSession, String>(new Model<>("")) { private static final long serialVersionUID = 1L; @Override public void populateItem(final Item<ICellPopulator<UIUserSession>> _cellItem, final String _componentId, final IModel<UIUserSession> _rowModel) { _cellItem.add(new AjaxLink<UIUserSession>(_componentId, _rowModel) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { final UIUserSession uiSession = (UIUserSession) getDefaultModelObject(); RegistryManager.invalidateSession(uiSession.getSessionId()); info(DBProperties.getFormatedDBProperty(SessionTablePanel.class.getName() + ".Feedback", new Object[] { uiSession.getSessionId() })); _target.addChildren(getPage(), FeedbackPanel.class); } @Override public void onComponentTagBody(final MarkupStream _markupStream, final ComponentTag _openTag) { replaceComponentTagBody(_markupStream, _openTag, ""); } }); } @Override public String getCssClass() { return "closeSessionLink"; } }); final String userName = DBProperties.getProperty(SessionTablePanel.class.getName() + ".UserName"); final String sessionId = DBProperties.getProperty(SessionTablePanel.class.getName() + ".SessionId"); final String lastActivity = DBProperties.getProperty(SessionTablePanel.class.getName() + ".LastActivity"); columns.add(new PropertyColumn<UIUserSession, String>(new Model<>(userName), "userName", "userName")); columns.add(new PropertyColumn<UIUserSession, String>(new Model<>(sessionId), "sessionId", "sessionId")); columns.add(new PropertyColumn<UIUserSession, String>(new Model<>(lastActivity), "lastActivity", "lastActivity")); add(new AjaxFallbackDefaultDataTable<>("table", columns, this.dataProvider, this.dataProvider.getRowsPerPage())); }
From source file:org.efaps.ui.wicket.pages.connection.ConnectionPage.java
License:Apache License
/** * @param _pageReference reference to the open page * @throws EFapsException on error/*from ww w . j a va2s. co m*/ */ public ConnectionPage(final PageReference _pageReference) throws EFapsException { final List<ITab> tabs = new ArrayList<ITab>(); tabs.add(new AbstractTab(new Model<String>("Sessions")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(final String _panelId) { Panel ret = null; try { ret = new SessionPanel(_panelId, _pageReference); } catch (final EFapsException e) { ConnectionPage.LOG.error("Could not load SessionPanel", e); } return ret; } }); if (Configuration.getAttributeAsBoolean(Configuration.ConfigAttribute.WEBSOCKET_ACTVATE)) { tabs.add(new AbstractTab(new Model<String>("Message")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(final String _panelId) { Panel ret = null; try { ret = new MessagePanel(_panelId, _pageReference); } catch (final EFapsException e) { ConnectionPage.LOG.error("Could not load SessionPanel", e); } return ret; } }); } add(new AjaxIndicatingTabbedPanel("tabs", tabs) { private static final long serialVersionUID = 1L; @Override protected void onAjaxUpdate(final AjaxRequestTarget _target) { super.onAjaxUpdate(_target); _target.addChildren(getPage(), FeedbackPanel.class); } }); add(new FeedbackPanel("feedback").setOutputMarkupId(true)); }
From source file:org.onexus.ui.authentication.persona.BrowserIdPanel.java
License:Apache License
protected Component getGuestPanel(String componentId) { return new GuestPanel(componentId, style) { private static final long serialVersionUID = 1L; @Override//from ww w . ja va2s.co m protected void onSuccess(AjaxRequestTarget target) { super.onSuccess(target); target.add(BrowserIdPanel.this); } @Override protected void onFailure(AjaxRequestTarget target, final String failureReason) { super.onFailure(target, failureReason); error("The authentication failed: " + failureReason); target.addChildren(getPage(), IFeedback.class); } }; }