org.apache.wicket.markup.html.WebPage Java Examples

The following examples show how to use org.apache.wicket.markup.html.WebPage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSecuredPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
private void addBreadCrumbs(final RepeatingView breadcrumbItems, final AbstractSecuredPage page)
{
  final WebPage returnTo = page.getReturnToPage();
  if (returnTo != null && returnTo instanceof AbstractSecuredPage) {
    addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo);
  }
  final WebMarkupContainer li = new WebMarkupContainer(breadcrumbItems.newChildId());
  breadcrumbItems.add(li);
  final Link<Void> pageLink = new Link<Void>("link") {

    @Override
    public void onClick()
    {
      setResponsePage(page);
    }
  };
  li.add(pageLink);
  pageLink.add(new Label("label", page.getTitle()));
}
 
Example #2
Source File: Self.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
            @SuppressWarnings("unchecked")
            final Class<? extends WebPage> beforeLogout = (Class<? extends WebPage>) SyncopeEnduserSession.get().
                    getAttribute(Constants.BEFORE_LOGOUT_PAGE);
            if (beforeLogout == null) {
                SyncopeEnduserSession.get().invalidate();
                setResponsePage(getApplication().getHomePage());
            } else {
                setResponsePage(beforeLogout);
            }
        } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            SyncopeEnduserSession.get().invalidate();

            final PageParameters parameters = new PageParameters();
            parameters.add(Constants.NOTIFICATION_MSG_PARAM, getString("self.wizard.success"));
            setResponsePage(getApplication().getHomePage(), parameters);
        }
    }
    super.onEvent(event);
}
 
Example #3
Source File: ReportDataPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public ReportDataPage(final ReportDefModel reportDef, final PageParameters pageParameters, final WebPage returnPage) {
	this.reportDefModel = reportDef;
	realSiteId = Locator.getFacade().getToolManager().getCurrentPlacement().getContext();
	if(pageParameters != null) {
		siteId = pageParameters.get("siteId").toString();
		inPrintVersion = pageParameters.get("printVersion").toBoolean(false);
	}
	if(siteId == null){
		siteId = realSiteId;
	}
	if(returnPage == null) {
		this.returnPage = new ReportsPage(pageParameters);			
	}else{
		this.returnPage = returnPage;
	}
	boolean allowed = Locator.getFacade().getStatsAuthz().isUserAbleToViewSiteStats(siteId);
	if(allowed) {
		if(reportDef != null && getReportDef() != null && getReportDef().getReportParams() != null) {
			renderBody();
		}else{
			setResponsePage(ReportsPage.class);
		}
	}else{
		setResponsePage(NotAuthorizedPage.class);
	}
}
 
Example #4
Source File: ReportDataPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public ReportDataPage(final ReportDefModel reportDef, final PageParameters pageParameters, final WebPage returnPage) {
	this.reportDefModel = reportDef;
	realSiteId = Locator.getFacade().getToolManager().getCurrentPlacement().getContext();
	if(pageParameters != null) {
		siteId = pageParameters.get("siteId").toString();
		inPrintVersion = pageParameters.get("printVersion").toBoolean(false);
	}
	if(siteId == null){
		siteId = realSiteId;
	}
	if(returnPage == null) {
		this.returnPage = new ReportsPage(pageParameters);			
	}else{
		this.returnPage = returnPage;
	}
	boolean allowed = Locator.getFacade().getStatsAuthz().isUserAbleToViewSiteStats(siteId);
	if(allowed) {
		if(reportDef != null && getReportDef() != null && getReportDef().getReportParams() != null) {
			renderBody();
		}else{
			setResponsePage(ReportsPage.class);
		}
	}else{
		setResponsePage(NotAuthorizedPage.class);
	}
}
 
Example #5
Source File: AbstractSecuredPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();
  final WebMarkupContainer breadcrumbContainer = new WebMarkupContainer("breadcrumb");
  body.add(breadcrumbContainer);
  breadcrumbContainer.add(contentMenuBarPanel);
  if (isBreadCrumbVisible() == true) {
    final RepeatingView breadcrumbItems = new RepeatingView("li");
    breadcrumbContainer.add(breadcrumbItems);
    final WebPage returnTo = this.getReturnToPage();
    if (returnTo != null && returnTo instanceof AbstractSecuredPage) {
      addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo);
    } else {
      breadcrumbItems.setVisible(false);
    }
    breadcrumbContainer.add(new Label("active", getTitle()));
  } else {
    breadcrumbContainer.setVisible(false);
  }
}
 
Example #6
Source File: AddressEditLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
public AddressEditLinkPanel(final String id, final WebPage returnToPage, final AddressDO address, final String addressText)
{
  super(id);
  add(new Link<Object>("link") {
    @Override
    public void onClick()
    {
      final PageParameters parameters = new PageParameters();
      parameters.add(AbstractEditPage.PARAMETER_KEY_ID, address.getId());
      final AddressEditPage editPage = new AddressEditPage(parameters);
      editPage.setReturnToPage(returnToPage);
      setResponsePage(editPage);
    }
  }.add(new Label("label", addressText).setRenderBodyOnly(true)));
}
 
Example #7
Source File: LinkProvider.java    From inception with Apache License 2.0 6 votes vote down vote up
public static ExternalLink createDocumentPageLink(Project aProject, long aDocId, String aId,
        String aLinkLabel, Class<? extends WebPage> aPageClass)
{
    String url = "";
    if (aDocId >= 0) {
        url = String.format("%s#!p=%d&d=%d",
                RequestCycle.get().urlFor(aPageClass, new PageParameters()), aProject.getId(),
                aDocId);
    }
    if (aLinkLabel == null) {
        new ExternalLink(aId, url);
    }
    
    return new ExternalLink(aId, url, aLinkLabel);
    
}
 
Example #8
Source File: AbstractEditPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the list page (declared as annotation) as response or, if given, the returnToPage.
 */
public void setResponsePage()
{
  if (this.returnToPage != null) {
    setResponsePageAndHighlightedRow(this.returnToPage);
  } else {
    final EditPage ann = getClass().getAnnotation(EditPage.class);
    final Class< ? extends WebPage> redirectPage;
    if (ann != null && ann.defaultReturnPage() != null) {
      redirectPage = getClass().getAnnotation(EditPage.class).defaultReturnPage();
    } else {
      redirectPage = WicketUtils.getDefaultPage();
    }
    final PageParameters params = new PageParameters();
    if (getData().getId() != null) {
      params.add(AbstractListPage.PARAMETER_HIGHLIGHTED_ROW, getData().getId());
    }
    setResponsePage(redirectPage, params);
  }
}
 
Example #9
Source File: AbstractEditPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Will be called directly after un-deleting the data object (update deleted=false). Any return value is not yet supported.
 */
@Override
public WebPage afterUndelete()
{
  // Do nothing at default.
  return null;
}
 
Example #10
Source File: LinkProvider.java    From inception with Apache License 2.0 5 votes vote down vote up
/**
 * Create an external link to a page which opens a document, codes the url as
 * {@code aPageClass?params#!p=projectId&d=docId}.
 */
public static ExternalLink createDocumentPageLink(DocumentService aDocService, Project aProject,
        String aDocId, String aId, String aLinkLabel, Class<? extends WebPage> aPageClass)
{
    long docId = -1;
    if (aDocService.existsSourceDocument(aProject, aDocId)) {
        docId = aDocService.getSourceDocument(aProject, aDocId).getId();
    }
    
    return createDocumentPageLink(aProject, docId, aId, aLinkLabel, aPageClass);
}
 
Example #11
Source File: UserRequestFormsWidget.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink getEventsLink(final String linkid) {
    BookmarkablePageLink<UserRequests> userRequests = BookmarkablePageLinkBuilder.build(linkid, UserRequests.class);
    MetaDataRoleAuthorizationStrategy.authorize(
            userRequests, WebPage.ENABLE, FlowableEntitlement.USER_REQUEST_FORM_LIST);
    return userRequests;
}
 
Example #12
Source File: MyAuthorizationStrategy.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
 */
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass)
{    if (WebPage.class.isAssignableFrom(componentClass) == true) {
  if (MySession.get().isAuthenticated() == true) {
    return true;
  }
  if (AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true
      || AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true
      || AbstractSecuredMobilePage.class.isAssignableFrom(componentClass) == true) {
    return false;
  }
}
return true;
}
 
Example #13
Source File: PageDelegate.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public PageDelegate(WebPage page, ORID pageOrid, ORID docOrid) {
	this.page = page;
	this.pageDocumentModel = new ODocumentModel(pageOrid);
	ODocument doc = (ODocument)(docOrid!=null?docOrid.getRecord():pageDocumentModel.getObject().field(PagesModule.OPROPERTY_DOCUMENT));
	if(doc!=null) page.setDefaultModel(new ODocumentModel(doc));
	String script = pageDocumentModel.getObject().field(PagesModule.OPROPERTY_SCRIPT);
	if(!Strings.isEmpty(script)) {
		OScriptManager scriptManager = Orient.instance().getScriptManager();
		ODatabaseDocument db = OrienteerWebSession.get().getDatabase();
		final OPartitionedObjectPool.PoolEntry<ScriptEngine> entry = 
				scriptManager.acquireDatabaseEngine(db.getName(), "javascript");
		final ScriptEngine scriptEngine = entry.object;
		Bindings binding = null;
	    try {
			binding = scriptManager.bind(scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE), 
											(ODatabaseDocumentTx) db, null, null);
			binding.put("page", page);
			binding.put("pageDoc", pageDocumentModel.getObject());
			binding.put("doc", doc);
			try {
				scriptEngine.eval(script);
			} catch (ScriptException e) {
				scriptManager.throwErrorMessage(e, script);
			}
		} finally {
			if (scriptManager != null && binding != null) {
				scriptManager.unbind(binding, null, null);
				scriptManager.releaseDatabaseEngine("javascript", db.getName(), entry);
			}
		}
	}
}
 
Example #14
Source File: WorkflowsViewer.java    From oodt with Apache License 2.0 5 votes vote down vote up
/**
 * @param id
 */
public WorkflowsViewer(String id, String workflowUrlStr,
    final Class<? extends WebPage> wViewerPage) {
  super(id);
  this.wm = new WorkflowMgrConn(workflowUrlStr);

  List<Workflow> workflows = this.wm.safeGetWorkflows();
  add(new ListView<Workflow>("workflow_list", workflows) {

    @Override
    protected void populateItem(ListItem<Workflow> item) {
      Workflow w = item.getModelObject();
      item.add(new Label("workflow_id", w.getId()));
      item.add(new Label("workflow_name", w.getName()));
      item.add(new Link<String>("workflow_link", new Model(w.getId())) {
        /*
         * (non-Javadoc)
         * 
         * @see org.apache.wicket.markup.html.link.Link#onClick()
         */
        @Override
        public void onClick() {
          PageParameters params = new PageParameters();
          params.add("id", getModelObject());
          setResponsePage(wViewerPage, params);
        }
      });
    }
  });

}
 
Example #15
Source File: EventToWorkflowViewer.java    From oodt with Apache License 2.0 5 votes vote down vote up
public EventToWorkflowViewer(String id, String workflowUrlStr, final Class<? extends WebPage> viewerPage) {
  super(id);
  this.wm = new WorkflowMgrConn(workflowUrlStr);
  WebMarkupContainer wTable = new WebMarkupContainer("wtable");
  wTable.setVisible(false);
  PropertyModel<List<Workflow>> workflowsModel = new PropertyModel<List<Workflow>>(this, "workflows");
  ListView<Workflow> workflowView = new ListView<Workflow>("workflow_list", workflowsModel) {
    private static final long serialVersionUID = 5894604290395257941L;

    @Override
    protected void populateItem(ListItem<Workflow> item) {
      Link<String> wLink = new Link<String>("workflow_link", new Model(item.getModelObject().getId())){
        
         /* (non-Javadoc)
         * @see org.apache.wicket.markup.html.link.Link#onClick()
         */
        @Override
        public void onClick() {
          PageParameters params = new PageParameters();
          params.add("id", getModelObject());
          setResponsePage(viewerPage, params);
        }
      };
      
      wLink.add(new Label("workflow_name", item.getModelObject().getName()));
      item.add(wLink);
    }
  };

  EventWorkflowForm form = 
    new EventWorkflowForm("event_workflow_frm", workflowsModel, wTable);

  wTable.add(workflowView);
  add(wTable);
  add(form);
}
 
Example #16
Source File: LoginPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param page
 * @param userDao
 * @param dataSource
 * @param username
 * @param password
 * @param userWantsToStayLoggedIn
 * @param defaultPage
 * @param targetUrlAfterLogin
 * @return i18n key of the validation error message if not successfully logged in, otherwise null.
 */
public static LoginResultStatus internalCheckLogin(final WebPage page, final UserDao userDao, final String username, final String password,
    final boolean userWantsToStayLoggedIn, final Class< ? extends WebPage> defaultPage)
{
  final LoginResult loginResult = Login.getInstance().checkLogin(username, password);
  final PFUserDO user = loginResult.getUser();
  if (user == null || loginResult.getLoginResultStatus() != LoginResultStatus.SUCCESS) {
    return loginResult.getLoginResultStatus();
  }
  if (UserFilter.isUpdateRequiredFirst() == true) {
    internalLogin(page, user);
    log.info("Admin login for maintenance (data-base update) successful for user '" + username + "'.");
    throw new RestartResponseException(SystemUpdatePage.class);
  }
  log.info("User successfully logged in: " + user.getDisplayUsername());
  if (userWantsToStayLoggedIn == true) {
    final PFUserDO loggedInUser = userDao.internalGetById(user.getId());
    final Cookie cookie = new Cookie("stayLoggedIn", loggedInUser.getId()
        + ":"
        + loggedInUser.getUsername()
        + ":"
        + userDao.getStayLoggedInKey(user.getId()));
    UserFilter.addStayLoggedInCookie(WicketUtils.getHttpServletRequest(page.getRequest()),
        WicketUtils.getHttpServletResponse(page.getResponse()), cookie);
  }
  internalLogin(page, user);
  // Do not redirect to requested page in maintenance mode (update required first):
  if (UserFilter.isUpdateRequiredFirst() == true) {
    throw new RestartResponseException(SystemUpdatePage.class);
  }
  page.continueToOriginalDestination();
  // Redirect only if not a redirect is set by Wicket.
  throw new RestartResponseException(defaultPage);
}
 
Example #17
Source File: AbstractMobileEditPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Will be called directly after deleting the data object (delete or update deleted=true). Any return value is not yet supported.
 */
@Override
public WebPage afterDelete()
{
  // Do nothing at default.
  return null;
}
 
Example #18
Source File: WebRegistry.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the both page classes as mount pages: mountPageBasename + "{List,Edit}.
 * @param mountPageBasename
 * @param pageListClass
 * @param pageEditClass
 * @return this for chaining.
 */
public WebRegistry addMountPages(final String mountPageBasename, final Class< ? extends WebPage> pageListClass,
    final Class< ? extends WebPage> pageEditClass)
{
  addMountPage(mountPageBasename + "List", pageListClass);
  addMountPage(mountPageBasename + "Edit", pageEditClass);
  return this;
}
 
Example #19
Source File: WebRegistry.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds all page classes as mount pages: mountPageBasename + "{List,Edit,View}.
 * @param mountPageBasename
 * @param pageListClass
 * @param pageEditClass
 * @param pageViewClass
 * @return this for chaining.
 */
public WebRegistry addMountPages(final String mountPageBasename, final Class< ? extends WebPage> pageListClass,
    final Class< ? extends WebPage> pageEditClass, final Class< ? extends WebPage> pageViewClass)
{
  addMountPage(mountPageBasename + "List", pageListClass);
  addMountPage(mountPageBasename + "Edit", pageEditClass);
  addMountPage(mountPageBasename + "View", pageViewClass);
  return this;
}
 
Example #20
Source File: AbstractListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractSecuredPage#getReturnToPage()
 */
@Override
public WebPage getReturnToPage()
{
  if (this.returnToPage != null) {
    return this.returnToPage;
  } else if (caller != null && caller instanceof WebPage) {
    return (WebPage) caller;
  }
  return null;
}
 
Example #21
Source File: AbstractEditPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Will be called directly after deleting the data object (delete or update deleted=true). Any return value is not yet supported.
 */
@Override
public WebPage afterDelete()
{
  // Do nothing at default.
  return null;
}
 
Example #22
Source File: MavenArtifactNotifierApplication.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends WebPage> getSignInPageClass() {
	return HomePage.class;
}
 
Example #23
Source File: AbstractSecuredMobilePage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * If set then return after save, update or cancel to this page. If not given then return to given list page. As an alternative you can
 * set the returnToPage as a page parameter (if supported by the derived page).
 * @param returnToPage
 */
public AbstractSecuredMobilePage setReturnToPage(final WebPage returnToPage)
{
  this.returnToPage = returnToPage;
  return this;
}
 
Example #24
Source File: AddressCampaignValueListPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public List<IColumn<AddressDO, String>> createColumns(final WebPage returnToPage, final boolean sortable, final boolean massUpdateMode)
{
  return createColumns(returnToPage, sortable, massUpdateMode, form.getSearchFilter(), personalAddressMap, addressCampaignValueMap);
}
 
Example #25
Source File: ForgottenPasswordPage.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<? extends WebPage> getFirstMenuPage() {
	return ForgottenPasswordPage.class;
}
 
Example #26
Source File: AbstractMobileEditPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WebPage onUndelete()
{
  return null;
}
 
Example #27
Source File: AbstractMobileEditPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WebPage onSaveOrUpdate()
{
  return null;
}
 
Example #28
Source File: AbstractMobileEditPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WebPage onDelete()
{
  return null;
}
 
Example #29
Source File: AdministrationUserGroupPortfolioPage.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<? extends WebPage> getSecondMenuPage() {
	return AdministrationUserGroupPortfolioPage.class;
}
 
Example #30
Source File: CalendarPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
private void modifyEvent(final Event event, final DateTime newStartTime, final DateTime newEndTime, final CalendarDropMode dropMode,
    final CalendarResponse response)
{
  final String eventId = event != null ? event.getId() : null;
  final String eventClassName = event != null ? event.getClassName() : null;
  if (eventId != null && TimesheetEventsProvider.EVENT_CLASS_NAME.equals(eventClassName) == true) {
    // User clicked on a time sheet, show the time sheet:
    final Integer id = NumberHelper.parseInteger(eventId);
    final TimesheetDO dbTimesheet = timesheetDao.internalGetById(id);
    if (dbTimesheet == null) {
      return;
    }
    final TimesheetDO timesheet = new TimesheetDO();
    timesheet.copyValuesFrom(dbTimesheet);
    final Long newStartTimeMillis = newStartTime != null ? DateHelper.getDateTimeAsMillis(newStartTime) : null;
    final Long newEndTimeMillis = newEndTime != null ? DateHelper.getDateTimeAsMillis(newEndTime) : null;
    if (newStartTimeMillis != null) {
      timesheet.setStartDate(newStartTimeMillis);
    }
    if (newEndTimeMillis != null) {
      timesheet.setStopTime(new Timestamp(newEndTimeMillis));
    }
    final PFUserDO loggedInUser = PFUserContext.getUser();
    if (CalendarDropMode.MOVE_SAVE.equals(dropMode) == true || CalendarDropMode.MOVE_EDIT.equals(dropMode) == true) {
      if (timesheetDao.hasUpdateAccess(loggedInUser, timesheet, dbTimesheet, false) == false) {
        // User has no update access, therefore ignore this request...
        return;
      }
      if (CalendarDropMode.MOVE_SAVE.equals(dropMode) == true) {
        timesheetDao.update(timesheet);
        setResponsePage(getPage());
      } else {
        setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage((WebPage) getPage()));
      }
      return;
    }
    // Copy this time sheet:
    timesheet.setId(null);
    timesheet.setDeleted(false);
    timesheetDao.setUser(timesheet, loggedInUser.getId()); // Copy for own user.
    if (CalendarDropMode.COPY_SAVE.equals(dropMode) == true) {
      if (timesheetDao.hasInsertAccess(loggedInUser, timesheet, false) == false) {
        // User has no insert access, therefore ignore this request...
        return;
      }
      timesheetDao.save(timesheet);
      setResponsePage(getPage());
      return;
    } else if (CalendarDropMode.COPY_EDIT.equals(dropMode) == true) {
      setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage((WebPage) getPage()));
    } else {
      // CANCEL -> should be handled through javascript now
      setResponsePage(getPage());
    }
  } else {
    onModifyEventHook(event, newStartTime, newEndTime, dropMode, response);
  }
}