List of usage examples for org.apache.wicket.markup.html.link Link setOutputMarkupId
public final Component setOutputMarkupId(final boolean output)
From source file:it.av.eatt.web.page.BasePage.java
License:Apache License
/** * Construct./*w ww .ja va 2s.c om*/ */ public BasePage() { if (((SecuritySession) getSession()).getAuth() != null && ((SecuritySession) getSession()).getAuth().isAuthenticated()) { isAuthenticated = true; } loggedInUser = ((SecuritySession) getSession()).getLoggedInUser(); if (getWebRequestCycle().getWebRequest().getCookie(CookieUtil.LANGUAGE) != null) { getSession().setLocale( new Locale(getWebRequestCycle().getWebRequest().getCookie(CookieUtil.LANGUAGE).getValue())); } else { if (loggedInUser != null) { getWebRequestCycle().getWebResponse() .addCookie(new Cookie(CookieUtil.LANGUAGE, loggedInUser.getLanguage().getLanguage())); getSession().setLocale(new Locale(loggedInUser.getLanguage().getLanguage())); } } // add(JavascriptPackageResource.getHeaderContribution(BASEPAGE_JS)); add(CSSPackageResource.getHeaderContribution(STYLES_CSS)); feedbackPanel = new FeedbackPanel("feedBackPanel"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); ResourceReference img = new ResourceReference(this.getClass(), "resources/images/logo-mela.png"); add(new Image("logo", img)); add(new AjaxLink<String>("goUserPage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserManagerPage.class)) { setResponsePage(UserManagerPage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserManagerPage.class))); } /*To Show a JS alert on protected area * @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCallDecorator() { private static final long serialVersionUID = 1L; public CharSequence decorateScript(CharSequence script) { if (!(getApplication().getSecuritySettings().getAuthorizationStrategy().isInstantiationAuthorized(UserManagerPage.class))) { return "alert('" + new StringResourceModel("basePage.notLogged", getPage(), null).getString() + "'); " + script; } return script; } }; }*/ }); add(new AjaxLink<String>("goUserProfilePage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserProfilePage.class)) { setResponsePage(UserProfilePage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserProfilePage.class))); } }); add(new AjaxLink<String>("goSearchRistorantePage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserHomePage.class)) { setResponsePage(UserHomePage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserHomePage.class))); } }); add(new AjaxLink<String>("goRistoranteAddNewPage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(RistoranteAddNewPage.class)) { setResponsePage(RistoranteAddNewPage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(RistoranteAddNewPage.class))); } }); add(new AjaxLink<String>("goSearchFriendPage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(SearchFriendPage.class)) { setResponsePage(SearchFriendPage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(SearchFriendPage.class))); } }); add(new AjaxLink<String>("goFriendPage") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(FriendsPage.class)) { setResponsePage(FriendsPage.class); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(FriendsPage.class))); } }); Link<String> goItalian = new Link<String>("goItalian") { @Override public void onClick() { getSession().setLocale(Locales.ITALIAN); getWebRequestCycle().getWebResponse() .addCookie(new Cookie(CookieUtil.LANGUAGE, Locales.ITALIAN.getLanguage())); } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (getSession().getLocale().getLanguage().equals(Locales.ITALIAN.getLanguage())) { tag.getAttributes().put("class", "selected"); } } }; add(goItalian); Link<String> goEnglish = new Link<String>("goEnglish") { @Override public void onClick() { getSession().setLocale(Locales.ENGLISH); getWebRequestCycle().getWebResponse() .addCookie(new Cookie(CookieUtil.LANGUAGE, Locales.ENGLISH.getLanguage())); } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (getSession().getLocale().getLanguage().equals(Locales.ENGLISH.getLanguage())) { tag.getAttributes().put("class", "selected"); } } }; add(goEnglish); Link<String> goDutch = new Link<String>("goDutch") { @Override public void onClick() { getWebRequestCycle().getWebResponse() .addCookie(new Cookie(CookieUtil.LANGUAGE, Locales.DUTCH.getLanguage())); getSession().setLocale(Locales.DUTCH); } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (getSession().getLocale().getLanguage().equals(Locales.DUTCH.getLanguage())) { tag.getAttributes().put("class", "selected"); } } }; add(goDutch); Link<String> goSignOut = new Link<String>("goSignOut") { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(SignOut.class); } }; Link<String> goSignIn = new Link<String>("goSignIn") { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(SignIn.class); } }; goSignIn.setOutputMarkupId(true); goSignOut.setOutputMarkupId(true); if (isAuthenticated) { goSignIn.setVisible(false); goSignOut.setVisible(true); } else { goSignOut.setVisible(false); goSignIn.setVisible(true); } add(goSignOut); add(goSignIn); Link<String> goAccount = new Link<String>("goAccount") { private static final long serialVersionUID = 1L; @Override public void onClick() { Eater eater = getLoggedInUser(); if (eater != null) { PageParameters pp = new PageParameters(YoueatHttpParams.PARAM_YOUEAT_ID + "=" + eater.getId()); setResponsePage(UserAccountPage.class, pp); } } @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserAccountPage.class))); } @Override protected boolean callOnBeforeRenderIfNotVisible() { return true; } }; add(goAccount); }
From source file:org.apache.jetspeed.portlets.rpad.RemotePortletAppDeployer.java
License:Apache License
@SuppressWarnings("unchecked") public RemotePortletAppDeployer() { deployer = new JetspeedPortletDeployer(); Form form = new Form("form"); repositories = getRepositoryManager().getRepositories(); form.add(new DropDownChoice("repositorySelection", new PropertyModel(this, "selectedRepository"), repositories, new ChoiceRenderer("name", "name"))); Button selectButton = new Button("selectButton") { private static final long serialVersionUID = 1L; public void onSubmit() { }/*from ww w. ja v a 2s.c o m*/ }; form.add(selectButton); add(form); IModel getRepo = new LoadableDetachableModel() { protected Object load() { return getRepo(); } }; final PageableListView listview = new PageableListView("repositories", getRepo, 10) { private static final long serialVersionUID = 1L; // This method is called for each 'entry' in the list. @Override protected void populateItem(final ListItem item) { final PortletApplication application = (PortletApplication) item.getModelObject(); item.add(new Label("groupId", application.getGroupId())); item.add(new Label("artifactId", application.getArtifactId())); item.add(new Label("name", application.getName())); item.add(new Label("version", application.getVersion())); item.add(new Label("type", application.getPackaging())); Link actionLink = new Link("action", item.getModel()) { public void onClick() { PortletApplication portletApplication = (PortletApplication) getModelObject(); deployer.deploy(portletApplication, getServiceLocator().getDeploymentManager()); } }; actionLink.setVisibilityAllowed(true); actionLink.setOutputMarkupId(true); if (deployer.getStatus() == PortletDeployer.DEPLOYING) { actionLink.setVisible(false); } item.add(actionLink); } }; listview.setOutputMarkupId(true); final WebMarkupContainer tableGroup = new WebMarkupContainer("tableGroup"); tableGroup.setOutputMarkupId(true); //tableGroup.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); tableGroup.add(new PagingNavigator("navigator", listview)); tableGroup.add(listview); final MultiLineLabel statusLabel = new MultiLineLabel("status", new PropertyModel(this, "message")); statusLabel.setOutputMarkupId(true); final Label tickerLabel = new Label("ticker", new PropertyModel(this, "ticker")); tickerLabel.setOutputMarkupId(true); add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) { protected void onTimer(AjaxRequestTarget target) { setMessage(deployer.getMessage()); target.addComponent(tickerLabel); target.addComponent(statusLabel); target.addComponent(tableGroup); } }); add(statusLabel); add(tickerLabel); add(tableGroup); }
From source file:org.headsupdev.agile.web.components.issues.IssuePanelRow.java
License:Open Source License
public IssuePanelRow(String id, Issue issue, final HeadsUpPage page, final boolean hideProject, final boolean hideMilestone, boolean hideAssignee) { super(id);/* w w w.j av a 2 s.c om*/ issue = (Issue) ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession().load(Issue.class, issue.getInternalId()); this.issue = issue; User currentUser = page.getSession().getUser(); add(CSSPackageResource.getHeaderContribution(getClass(), "issue.css")); final boolean timeEnabled = Boolean.parseBoolean( page.getProject().getConfigurationValue(StoredProject.CONFIGURATION_TIMETRACKING_ENABLED)); PageParameters params = new PageParameters(); params.add("project", issue.getProject().getId()); params.add("id", String.valueOf(issue.getId())); WebMarkupContainer cell = new WebMarkupContainer("id-cell"); Class<? extends Page> viewClass = page.getPageClass("issues/view"); if (viewClass != null) { Link idLink = new BookmarkablePageLink("id-link", viewClass, params); idLink.add(new Label("id-label", String.valueOf(issue.getId()))); cell.add(idLink); cell.add(new WebMarkupContainer("id-label").setVisible(false)); } else { cell.add(new WebMarkupContainer("id-link").setVisible(false)); cell.add(new Label("id-label", String.valueOf(issue.getId()))); } add(cell); cell = new WebMarkupContainer("summary-cell"); if (viewClass != null) { Link summaryLink = new BookmarkablePageLink("summary-link", viewClass, params); summaryLink.add(new Label("summary-label", issue.getSummary())); cell.add(summaryLink); cell.add(new WebMarkupContainer("summary-label").setVisible(false)); } else { cell.add(new WebMarkupContainer("summary-link").setVisible(false)); cell.add(new Label("summary-label", issue.getSummary())); } add(cell); Label label = new Label("project", (issue.getProject() == null) ? "" : issue.getProject().toString()); add(label.setVisible(!hideProject)); add(new Label("order", issue.getOrder() == null ? "" : String.valueOf(issue.getOrder()))); add(new Label("status", IssueUtils.getStatusDescription(issue))); WebMarkupContainer type = new WebMarkupContainer("type"); add(type); final String issueType = IssueUtils.getTypeName(issue.getType()); String typeIcon = "type/" + issueType + ".png"; type.add(new Image("type-icon", new ResourceReference(IssueListPanel.class, typeIcon)) .add(new AttributeModifier("alt", true, new Model<String>() { @Override public String getObject() { return issueType; } })).add(new AttributeModifier("title", true, new Model<String>() { @Override public String getObject() { return issueType; } }))); String image = null; switch (issue.getPriority()) { case Issue.PRIORITY_BLOCKER: image = "blocker.png"; break; case Issue.PRIORITY_CRITICAL: image = "critical.png"; break; case Issue.PRIORITY_MINOR: image = "minor.png"; break; case Issue.PRIORITY_TRIVIAL: image = "trivial.png"; break; } if (image == null) { WebMarkupContainer ico = new WebMarkupContainer("priority-icon"); ico.setVisible(false); type.add(ico); } else { type.add(new Image("priority-icon", new ResourceReference(IssueListPanel.class, image))); } if (((HibernateStorage) Manager.getStorageInstance()).getResourceManager().isIssueMissingEstimate(issue)) { if (((HibernateStorage) Manager.getStorageInstance()).getResourceManager() .isIssueSeriouslyMissingEstimate(issue)) { type.add(new Image("overworked-icon", new ResourceReference(HeadsUpPage.class, "images/fail.png"))); } else { type.add(new Image("overworked-icon", new ResourceReference(HeadsUpPage.class, "images/warn.png"))); } } else { type.add(new WebMarkupContainer("overworked-icon").setVisible(false)); } boolean attachments = issue.getAttachments().size() > 0; Image attachImage = new Image("attachment-icon", new ResourceReference(IssueListPanel.class, "attach.png")); type.add(attachImage.setVisible(attachments)); cell = new WebMarkupContainer("assigned-cell"); if (!hideAssignee) { if (issue.getAssignee() != null) { params = new PageParameters(); params.add("project", issue.getProject().getId()); params.add("username", issue.getAssignee().getUsername()); Class<? extends Page> userClass = page.getPageClass("account"); if (userClass != null) { cell.add(new GravatarLinkPanel("gravatar", issue.getAssignee(), HeadsUpPage.SMALL_AVATAR_EDGE_LENGTH)); Link assignedLink = new BookmarkablePageLink("assigned-link", userClass, params); assignedLink.add(new Label("assigned-label", issue.getAssignee().getFullnameOrUsername())); cell.add(assignedLink); cell.add(new WebMarkupContainer("assigned-label").setVisible(false)); cell.add(new WebMarkupContainer("assign-link").setVisible(false)); cell.add(new WebMarkupContainer("assign-choice").setVisible(false)); } else { cell.add(new WebMarkupContainer("gravatar").setVisible(false)); cell.add(new WebMarkupContainer("assigned-link").setVisible(false)); cell.add(new Label("assigned-label", issue.getAssignee().getFullnameOrUsername())); cell.add(new WebMarkupContainer("assign-link").setVisible(false)); cell.add(new WebMarkupContainer("assign-choice").setVisible(false)); } } else { final UserDropDownChoice assignChoice = new UserDropDownChoice("assign-choice") { @Override protected boolean wantOnSelectionChangedNotifications() { return true; } @Override protected void onSelectionChanged(User newSelection) { IssuePanelRow.this.issue = (Issue) ((HibernateStorage) Manager.getStorageInstance()) .getHibernateSession().merge(IssuePanelRow.this.issue); // if we have an assignee that is not watching then add them to the watchers if (newSelection != null && !IssuePanelRow.this.issue.getWatchers().contains(newSelection)) { IssuePanelRow.this.issue.getWatchers().add(newSelection); } IssuePanelRow.this.issue.setAssignee(newSelection); } }; assignChoice.setModel(new PropertyModel<User>(issue, "assignee")); Link assignLink = new AjaxFallbackLink("assign-link") { @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { this.setVisible(false); ajaxRequestTarget.addComponent(this); assignChoice.setVisible(true); ajaxRequestTarget.addComponent(assignChoice); } }; cell.add(assignLink.setOutputMarkupId(true) .setVisible(Permissions.canEditIssue(currentUser, page.getProject()))); cell.add(new WebMarkupContainer("gravatar").setVisible(false)); cell.add( assignChoice.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).setVisible(false)); cell.add(new WebMarkupContainer("assigned-label").setVisible(false)); cell.add(new WebMarkupContainer("assigned-link").setVisible(false)); } } else { cell.add(new WebMarkupContainer("gravatar").setVisible(false)); cell.add(new WebMarkupContainer("assigned-link").setVisible(false)); cell.add(new WebMarkupContainer("assigned-label").setVisible(false)); cell.add(new WebMarkupContainer("assign-link").setVisible(false)); cell.add(new WebMarkupContainer("assign-choice").setVisible(false)); } add(cell.setVisible(!hideAssignee)); cell = new WebMarkupContainer("milestone-cell"); Milestone milestone = issue.getMilestone(); if (milestone == null) { cell.add(new WebMarkupContainer("milestone-link").setVisible(false)); cell.add(new WebMarkupContainer("milestone-label").setVisible(false)); final MilestoneDropDownChoice milestoneChoice = new MilestoneDropDownChoice("setmilestone-choice", issue.getProject()) { @Override protected boolean wantOnSelectionChangedNotifications() { return true; } @Override protected void onSelectionChanged(Milestone newSelection) { IssuePanelRow.this.issue = (Issue) ((HibernateStorage) Manager.getStorageInstance()) .getHibernateSession().merge(IssuePanelRow.this.issue); Milestone newMilestone = (Milestone) ((HibernateStorage) Manager.getStorageInstance()) .getHibernateSession().merge(newSelection); IssuePanelRow.this.issue.setMilestone(newMilestone); } }; milestoneChoice.setModel(new PropertyModel<Milestone>(issue, "milestone")); Link setMilestoneLink = new AjaxFallbackLink("setmilestone-link") { @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { this.setVisible(false); ajaxRequestTarget.addComponent(this); milestoneChoice.setVisible(true); ajaxRequestTarget.addComponent(milestoneChoice); } }; cell.add(setMilestoneLink.setOutputMarkupId(true) .setVisible(Permissions.canEditIssue(currentUser, page.getProject()))); cell.add(milestoneChoice.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).setVisible(false)); } else { params = new PageParameters(); params.add("project", milestone.getProject().getId()); params.add("id", milestone.getName()); Class<? extends Page> milestoneClass = page.getPageClass("milestones/view"); if (milestoneClass != null) { Link milestoneLink = new BookmarkablePageLink("milestone-link", milestoneClass, params); milestoneLink.add(new Label("milestone-label", milestone.toString())); cell.add(milestoneLink); cell.add(new WebMarkupContainer("milestone-label").setVisible(false)); } else { cell.add(new WebMarkupContainer("milestone-link").setVisible(false)); cell.add(new Label("milestone-label", milestone.toString())); } cell.add(new WebMarkupContainer("setmilestone-link").setVisible(false)); cell.add(new WebMarkupContainer("setmilestone-choice").setVisible(false)); } add(cell.setVisible(!hideMilestone)); cell = new WebMarkupContainer("hours-cell"); cell.add(new Label("hours", new IssueHoursRemainingModel(issue))); add(cell.setVisible(timeEnabled)); }