Example usage for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink.

Prototype

public AjaxLink(final String id, final IModel<T> model) 

Source Link

Document

Construct.

Usage

From source file:it.av.eatt.web.page.SearchFriendTableActionPanel.java

License:Apache License

/**
 * @param id component id/*ww  w  . ja  v a  2 s  . co m*/
 * @param model model for contact
 */
public SearchFriendTableActionPanel(String id, IModel<Eater> model) {
    super(id, model);
    add(new AjaxLink<Eater>("addFriend", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            SearchFriendPage page = ((SearchFriendPage) getPage());
            try {
                userRelationService.addFriendRequest(page.getLoggedInUser(), getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getSearchFriendsContainer());
                info(new StringResourceModel("friendRequestSent", this, null).getString());
            } catch (JackWicketException e) {
                error(new StringResourceModel("genericErrorMessage", this, null).getString());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
    add(new AjaxLink<Eater>("followUser", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            SearchFriendPage page = ((SearchFriendPage) getPage());
            try {
                userRelationService.addFollowUser(page.getLoggedInUser(), getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getSearchFriendsContainer());
                info(new StringResourceModel("followUserDone", this, null).getString());
            } catch (JackWicketException e) {
                error(new StringResourceModel("genericErrorMessage", this, null).getString());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
}

From source file:it.av.eatt.web.page.UserManagerPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * //from ww  w . j a va  2 s  . c o m
 * @throws JackWicketException
 */
public UserManagerPage() throws JackWicketException {

    form = new Form<Eater>("userForm", new CompoundPropertyModel<Eater>(new Eater()));
    form.setOutputMarkupId(true);
    form.add(new TextField<String>("password"));
    form.add(new TextField<String>("lastname"));
    form.add(new TextField<String>("firstname"));
    form.add(new TextField<String>("email"));
    form.add(new DropDownChoice<EaterProfile>("userProfile",
            new ArrayList<EaterProfile>(userProfileService.getAll()), new UserProfilesList())
                    .setOutputMarkupId(true));

    form.add(new AjaxLink<Eater>("buttonClearForm", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            form.setModelObject(new Eater());
            target.addComponent(form);
        }
    });
    form.add(new SubmitButton("ajax-button", form));
    add(form);

    List<IColumn<Eater>> columns = new ArrayList<IColumn<Eater>>();
    columns.add(new AbstractColumn<Eater>(new Model<String>(
            new StringResourceModel("datatableactionpanel.actions", this, null).getString())) {
        public void populateItem(Item<ICellPopulator<Eater>> cellItem, String componentId,
                IModel<Eater> model) {
            cellItem.add(new UserTableActionPanel(componentId, model));
        }
    });
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("firstname", this, null).getString()), "firstname"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("lastname", this, null).getString()), "lastname"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("email", this, null).getString()), "email"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("userProfile", this, null).getString()),
            "userProfile.name"));
    dataProvider = new UserSortableDataProvider();
    usersDataTable = new AjaxFallbackDefaultDataTable<Eater>("usersDataTable", columns, dataProvider, 10);
    add(usersDataTable);
    searchPanel = new SearchPanel(dataProvider, usersDataTable, "searchPanel", getFeedbackPanel());
    add(searchPanel);
}

From source file:it.av.eatt.web.page.UserProfilePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * //from  w w  w  . j a v  a 2 s .  c  o  m
 * @throws JackWicketException
 */
public UserProfilePage() throws JackWicketException {
    userProfile = new EaterProfile();

    form = new Form<EaterProfile>("userProfileForm", new CompoundPropertyModel<EaterProfile>(userProfile));
    form.setOutputMarkupId(true);
    form.add(new RequiredTextField<String>("name"));
    form.add(new TextField<String>("description"));

    form.add(new AjaxLink<EaterProfile>("buttonClearForm", new Model<EaterProfile>(userProfile)) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            form.setModelObject(new EaterProfile());
            target.addComponent(form);
        }
    });
    form.add(new SubmitButton("ajax-button", form));
    add(form);

    List<IColumn<EaterProfile>> columns = new ArrayList<IColumn<EaterProfile>>();
    columns.add(new AbstractColumn<EaterProfile>(new Model<String>(
            new StringResourceModel("datatableactionpanel.actions", this, null).getString())) {
        public void populateItem(Item<ICellPopulator<EaterProfile>> cellItem, String componentId,
                IModel<EaterProfile> model) {
            cellItem.add(new UserProfileTableActionPanel(componentId, model));
        }
    });
    columns.add(new PropertyColumn<EaterProfile>(
            new Model<String>(new StringResourceModel("name", this, null).getString()), "name"));
    columns.add(new PropertyColumn<EaterProfile>(
            new Model<String>(new StringResourceModel("description", this, null).getString()), "description"));
    dataProvider = new UserProfileSortableDataProvider();
    refreshDataTable();
    usersProfileDataTable = new AjaxFallbackDefaultDataTable<EaterProfile>("usersDataTable", columns,
            dataProvider, 10);
    add(usersProfileDataTable);

}

From source file:it.av.eatt.web.page.UserProfileTableActionPanel.java

License:Apache License

/**
 * @param id component id/*from   w  ww  .  j a v a 2  s.  com*/
 * @param model model for contact
 */
public UserProfileTableActionPanel(String id, IModel<EaterProfile> model) {
    super(id, model);
    add(new AjaxLink<EaterProfile>("edit", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserProfilePage page = ((UserProfilePage) getPage());
            Form<EaterProfile> form = page.getForm();
            form.setModelObject(getModelObject());
            target.addComponent(form);
            page.getFeedbackPanel()
                    .info("Profile \"" + getModelObject().getName() + "\" loaded and ready to be modified");
            target.addComponent(page.getFeedbackPanel());
        }
    });
    add(new AjaxLink<EaterProfile>("remove", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserProfilePage page = ((UserProfilePage) getPage());
            String profileName = getModelObject().getName();
            page.add(page.getFeedbackPanel());
            try {
                ((UserProfilePage) getPage()).getUsersProfileServices().remove(getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getUsersProfileDataTable());
                page.getFeedbackPanel().info("Profile \"" + profileName + "\" removed");
            } catch (JackWicketException e) {
                page.getFeedbackPanel().error(e.getMessage());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
}

From source file:it.av.eatt.web.page.UserTableActionPanel.java

License:Apache License

/**
 * @param id component id/*from  w w  w. j  av a 2  s  . c  o m*/
 * @param model model for contact
 */
public UserTableActionPanel(String id, IModel<Eater> model) {
    super(id, model);
    add(new AjaxLink<Eater>("select", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserManagerPage page = ((UserManagerPage) getPage());
            page.getForm().setModelObject(getModelObject());
            target.addComponent(page.getForm());
        }
    });
    add(new AjaxLink<Eater>("edit", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Form<Eater> form = ((UserManagerPage) getPage()).getForm();
            form.setModelObject(getModelObject());
            target.addComponent(form);
        }
    });
    add(new AjaxLink<Eater>("remove", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserManagerPage page = ((UserManagerPage) getPage());
            String userName = getModelObject().getFirstname() + " " + getModelObject().getLastname();
            try {
                page.getUsersServices().remove(getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getUsersDataTable());
                page.getFeedbackPanel().info("Eater \"" + userName + "\" removed");
            } catch (JackWicketException e) {
                page.getFeedbackPanel().error(e.getMessage());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
}

From source file:it.av.youeat.web.page.UserManagerPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * /*from   ww  w.  j ava2  s  .  c  o  m*/
 * @throws YoueatException
 */
public UserManagerPage() throws YoueatException {

    form = new Form<Eater>("userForm", new CompoundPropertyModel<Eater>(new Eater()));
    form.setOutputMarkupId(true);
    form.add(new TextField<String>("password"));
    form.add(new TextField<String>("lastname"));
    form.add(new TextField<String>("firstname"));
    form.add(new TextField<String>("email"));
    form.add(new DropDownChoice<EaterProfile>("userProfile",
            new ArrayList<EaterProfile>(userProfileService.getAll()), new UserProfilesList())
                    .setOutputMarkupId(true));

    form.add(new AjaxLink<Eater>("buttonClearForm", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            form.setModelObject(new Eater());
            target.addComponent(form);
        }
    });
    form.add(new SubmitButton("ajax-button", form));
    add(form);

    List<IColumn<Eater>> columns = new ArrayList<IColumn<Eater>>();
    columns.add(new AbstractColumn<Eater>(new Model<String>(
            new StringResourceModel("datatableactionpanel.actions", this, null).getString())) {
        public void populateItem(Item<ICellPopulator<Eater>> cellItem, String componentId,
                IModel<Eater> model) {
            cellItem.add(new UserTableActionPanel(componentId, model));
        }
    });
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("firstname", this, null).getString()), "firstname",
            "firstname"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("lastname", this, null).getString()), "lastname",
            "lastname"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("email", this, null).getString()), "email", "email"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel("userProfile", this, null).getString()),
            "userProfile.name"));
    columns.add(new PropertyColumn<Eater>(
            new Model<String>(new StringResourceModel(Eater.CREATIONTIME, this, null).getString()),
            Eater.CREATIONTIME, Eater.CREATIONTIME));
    dataProvider = new UserSortableDataProvider();
    usersDataTable = new AjaxFallbackDefaultDataTable<Eater>("usersDataTable", columns, dataProvider, 10);
    add(usersDataTable);
    searchPanel = new UserManagerUserSearchPanel(dataProvider, usersDataTable, "searchPanel",
            getFeedbackPanel());
    add(searchPanel);

    add(new AjaxLink<Eater>("indexDataRistorante", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            dataRistoranteService.indexData();
        }
    });
    add(new AjaxLink<Eater>("indexCity", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            cityService.getAll();
        }
    });

    add(new AjaxLink<Eater>("indexRisto", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            ristoranteService.indexData();
        }
    });

    add(new AjaxLink<Eater>("indexUsers", new Model<Eater>()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            userService.indexData();
        }
    });

}

From source file:it.av.youeat.web.page.UserProfilePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * /*from  www.jav a2s . com*/
 * @throws YoueatException
 */
public UserProfilePage() throws YoueatException {
    userProfile = new EaterProfile();

    form = new Form<EaterProfile>("userProfileForm", new CompoundPropertyModel<EaterProfile>(userProfile));
    form.setOutputMarkupId(true);
    form.add(new RequiredTextField<String>("name"));
    form.add(new TextField<String>("description"));

    form.add(new AjaxLink<EaterProfile>("buttonClearForm", new Model<EaterProfile>(userProfile)) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            form.setModelObject(new EaterProfile());
            target.addComponent(form);
        }
    });
    form.add(new SubmitButton("ajax-button", form));
    add(form);

    List<IColumn<EaterProfile>> columns = new ArrayList<IColumn<EaterProfile>>();
    columns.add(new AbstractColumn<EaterProfile>(new Model<String>(
            new StringResourceModel("datatableactionpanel.actions", this, null).getString())) {
        public void populateItem(Item<ICellPopulator<EaterProfile>> cellItem, String componentId,
                IModel<EaterProfile> model) {
            cellItem.add(new UserProfileTableActionPanel(componentId, model));
        }
    });
    columns.add(new PropertyColumn<EaterProfile>(
            new Model<String>(new StringResourceModel("name", this, null).getString()), "name"));
    columns.add(new PropertyColumn<EaterProfile>(
            new Model<String>(new StringResourceModel("description", this, null).getString()), "description"));
    dataProvider = new UserProfileSortableDataProvider();
    refreshDataTable();
    usersProfileDataTable = new AjaxFallbackDefaultDataTable<EaterProfile>("usersDataTable", columns,
            dataProvider, 10);
    add(usersProfileDataTable);

}

From source file:it.av.youeat.web.panel.UserProfileTableActionPanel.java

License:Apache License

/**
 * @param id component id//w w w . java  2s .c o m
 * @param model model for contact
 */
public UserProfileTableActionPanel(String id, IModel<EaterProfile> model) {
    super(id, model);
    add(new AjaxLink<EaterProfile>("edit", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserProfilePage page = ((UserProfilePage) getPage());
            Form<EaterProfile> form = page.getForm();
            form.setModelObject(getModelObject());
            target.addComponent(form);
            page.getFeedbackPanel()
                    .info("Profile \"" + getModelObject().getName() + "\" loaded and ready to be modified");
            target.addComponent(page.getFeedbackPanel());
        }
    });
    add(new AjaxLink<EaterProfile>("remove", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserProfilePage page = ((UserProfilePage) getPage());
            String profileName = getModelObject().getName();
            page.add(page.getFeedbackPanel());
            try {
                ((UserProfilePage) getPage()).getUsersProfileServices().remove(getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getUsersProfileDataTable());
                page.getFeedbackPanel().info("Profile \"" + profileName + "\" removed");
            } catch (YoueatException e) {
                page.getFeedbackPanel().error(e.getMessage());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
}

From source file:it.av.youeat.web.panel.UserTableActionPanel.java

License:Apache License

/**
 * @param id component id/*from w ww  .  j a v  a2  s . com*/
 * @param model model for contact
 */
public UserTableActionPanel(String id, IModel<Eater> model) {
    super(id, model);
    add(new AjaxLink<Eater>("select", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserManagerPage page = ((UserManagerPage) getPage());
            page.getForm().setModelObject(getModelObject());
            target.addComponent(page.getForm());
        }
    });
    add(new AjaxLink<Eater>("edit", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Form<Eater> form = ((UserManagerPage) getPage()).getForm();
            form.setModelObject(getModelObject());
            target.addComponent(form);
        }
    });
    add(new AjaxLink<Eater>("remove", model) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserManagerPage page = ((UserManagerPage) getPage());
            String userName = getModelObject().getFirstname() + " " + getModelObject().getLastname();
            try {
                page.getUsersServices().remove(getModelObject());
                page.refreshDataTable();
                target.addComponent(page.getUsersDataTable());
                page.getFeedbackPanel().info("Eater \"" + userName + "\" removed");
            } catch (YoueatException e) {
                page.getFeedbackPanel().error(e.getMessage());
            }
            target.addComponent(page.getFeedbackPanel());
        }
    });
}

From source file:jp.go.nict.langrid.management.web.view.page.language.service.composite.component.panel.ServiceInUseListPanel.java

License:Open Source License

@Override
protected void createList() throws ServiceManagerException {
    Map<InvocationModel, Pair<Boolean, String>> existList = new LinkedHashMap<InvocationModel, Pair<Boolean, String>>();
    Map<InvocationModel, Pair<Boolean, String>> otherList = new LinkedHashMap<InvocationModel, Pair<Boolean, String>>();

    ServiceFactory f = ServiceFactory.getInstance();

    for (InvocationModel invocation : invocations) {
        LangridServiceService<ServiceModel> service = f.getLangridServiceService(invocation.getServiceGridId());
        ServiceModel model = service.get(invocation.getServiceId());

        if (model != null) {
            if (model.getServiceType() != null && !model.getServiceType().getTypeId().equals("Other")) {
                existList.put(invocation,
                        new Pair<Boolean, String>(true, model.getServiceType().getTypeName()));
            } else {
                otherList.put(invocation, new Pair<Boolean, String>(true, "Other"));
            }//  w ww  .  j  av  a  2 s. c  om
        } else {
            if (StringUtil.isValidString(invocation.getServiceTypeId())
                    && !invocation.getServiceTypeId().equals("Other")) {
                ServiceTypeModel stm = ServiceFactory.getInstance().getServiceTypeService("")
                        .get(invocation.getDomainId(), invocation.getServiceTypeId());
                if (!stm.getTypeId().equals("Other")) {
                    existList.put(invocation, new Pair<Boolean, String>(false, invocation.getServiceTypeId()));
                } else {
                    otherList.put(invocation, new Pair<Boolean, String>(false, "Other"));
                }
            } else {
                otherList.put(invocation, new Pair<Boolean, String>(false, "Other"));
            }
        }
    }
    add(new ServiceInUsePanel("existList", existList));
    WebMarkupContainer otherContainer = new WebMarkupContainer("otherContainer");
    add(otherContainer);
    ServiceInUsePanel siup = new ServiceInUsePanel("otherList", otherList);
    otherContainer.add(siup);
    siup.setOutputMarkupId(true);
    siup.setOutputMarkupPlaceholderTag(true);
    siup.setVisible(false);
    otherContainer.add(new AjaxLink<ServiceInUsePanel>("isVisibleOther", new Model<ServiceInUsePanel>(siup)) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            getModelObject().setVisible(!getModelObject().isVisible());
            target.addComponent(getModelObject());
        }
    });
    if (otherList.size() == 0) {
        otherContainer.setVisible(false);
    }
}