/**
  * Maps a trimmed value entered by the user to a value stored in the value list. The value stored
  * in the value list may contain some trailing spaces, while the value entered by the user is
  * trimmed.
  *
  * @param value
  * @return
  */
 @SuppressWarnings("nls")
 public String mapTrimmedToNotTrimmed(String value) {
   // Although the value entered by the user should be trimmed, make sure it is so.
   String trimmed = value.trim();
   try {
     // this is the &nbsp character we set for empty value
     if ("\u00A0".equals(trimmed) || trimmed.length() == 0) return trimmed;
     // Grab all values that start with the value entered by the user.
     String result = matchValueListValue(trimmed, false);
     if (result == null) {
       if (changeListener != null) dlm.getValueList().removeListDataListener(changeListener);
       try {
         dlm.fill(parentState, getDataProviderID(), trimmed, false);
         result = matchValueListValue(trimmed, false);
         if (result == null && list.hasRealValues()) {
           dlm.fill(parentState, getDataProviderID(), null, false);
           // if it doesn't have real values, just keep what is typed
           // now just try to match it be start with matching instead of equals:
           result = matchValueListValue(trimmed, true);
           if (result == null && !getEventExecutor().getValidationEnabled()) {
             result = trimmed;
           } else {
             // if this is found then it is a commit of data of a partial string, make sure that
             // the field is updated with the complete value.
             String displayValue = result == null ? "" : result;
             if (displayValue != null
                 && !displayValue.equals(trimmed)
                 && RequestCycle.get() != null) {
               IRequestTarget requestTarget = RequestCycle.get().getRequestTarget();
               if (requestTarget instanceof AjaxRequestTarget) {
                 ((AjaxRequestTarget) requestTarget)
                     .appendJavascript(
                         "if (document.getElementById('"
                             + getMarkupId()
                             + "').value == '"
                             + value
                             + "') document.getElementById('"
                             + getMarkupId()
                             + "').value='"
                             + displayValue
                             + "'");
               }
             }
           }
         }
       } finally {
         if (changeListener != null) dlm.getValueList().addListDataListener(changeListener);
       }
     }
     // If no match was found then return back the value, otherwise return the found match.
     return result == null ? trimmed : result;
   } catch (Exception e) {
     Debug.error(e);
     return trimmed;
   }
 }
示例#2
0
  private boolean handleUsernamePasswordParameters() {
    String iframeLoginUsername = RequestCycle.get().getRequest().getParameter("iframe_username");
    String iframeLoginPassword = RequestCycle.get().getRequest().getParameter("iframe_password");

    if (iframeLoginUsername != null && iframeLoginPassword != null) {
      boolean valid = ConstellioSession.get().signIn(iframeLoginUsername, iframeLoginPassword);
      if (valid) {
        ConstellioSession.get().signIn(iframeLoginUsername, iframeLoginPassword);
        WebRequestCycle.get().setResponsePage(SearchFormPage.class);
        return true;
      }
    }
    return false;
  }
示例#3
0
  private void onSubmit(Map<String, String> map) {
    PersistedObject po = (PersistedObject) getDefaultModelObject();

    if (!editorService.validateNameUpdate(po, map)) {
      editor.showError(
          new StringResourceModel(po.isBean() ? "beanNotUnique" : "endpointNotUnique", this, null)
              .getString());
      RequestCycle.get().setResponsePage(this);
      return;
    }

    editorService.updatePersistedObject(po, map);

    RequestCycle.get()
        .setResponsePage(new ShowServiceAssemblyPage(sadao.find(po.getServiceAssembly().getId())));
  }
 @Override
 protected void onBeforeRender() {
   super.onBeforeRender();
   IRequestTarget target = ((WebRequestCycle) RequestCycle.get()).getRequestTarget();
   if (target instanceof AjaxRequestTarget) {
     // if refreshed by ajax render it again
     ((AjaxRequestTarget) target).appendJavascript(getInitJs());
   }
 }
示例#5
0
 @Override
 public String getBrixLinkUrl(BrixNodeModel nodeModel, RequestCycle rc) {
   try {
     return rc.urlFor(new BrixNodeRequestTarget(nodeModel)).toString();
   } catch (JcrException e) {
     log.error("error creating brix node request target for node model: " + nodeModel, e);
   }
   return null;
 }
示例#6
0
  public LoginPage() {
    super();

    boolean logedIn = handleIFrameParameters();

    if (!logedIn) {
      ConstellioUser user = ConstellioSession.get().getUser();
      if (user != null) {
        PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
        if (user.isAdmin()) {
          RequestCycle.get().setResponsePage(pageFactoryPlugin.getAdminPage());
        } else {
          RequestCycle.get().setResponsePage(pageFactoryPlugin.getSearchFormPage());
        }
      }
      ConstellioSignInPanel signInPanel = new ConstellioSignInPanel("signInPanel");
      add(signInPanel);
    }
  }
  @Override
  protected void setHeaders(WebResponse response) {
    super.setHeaders(
        response); // To change body of overridden methods use File | Settings | File Templates.

    WebUtil.authenticate(
        (WebRequest) RequestCycle.get().getRequest(),
        response,
        new MilestoneViewPermission(),
        getProject());
  }
示例#8
0
 @Override
 protected void respond(AjaxRequestTarget target) {
   Request request = RequestCycle.get().getRequest();
   String items = request.getParameter("items");
   @SuppressWarnings("unchecked")
   List<T> modelList = (List<T>) SortableList.this.getDefaultModelObject();
   modelList.clear();
   for (String markupId : StringUtils.commaDelimitedListToStringArray(items)) {
     if (org.apache.commons.lang.StringUtils.isNotBlank(markupId))
       modelList.add(itemByMarkupId.get(markupId));
   }
 }
 /**
  * @see org.apache.wicket.RequestCycle#onRuntimeException(org.apache.wicket.Page,
  *     java.lang.RuntimeException)
  */
 @Override
 public Page onRuntimeException(Page page, RuntimeException e) {
   if (e instanceof PageExpiredException || e instanceof InvalidUrlException) {
     if (((WebRequest) RequestCycle.get().getRequest()).isAjax()) {
       Debug.log("ajax request with exception aborted ", e); // $NON-NLS-1$
       throw new AbortException();
     }
   }
   if (page instanceof MainPage && ((MainPage) page).getController() != null) {
     Debug.error(
         "Error rendering the page " + ((MainPage) page).getController().getName(),
         e); //$NON-NLS-1$
   } else {
     Debug.error("Error rendering the page " + page, e); // $NON-NLS-1$
   }
   return super.onRuntimeException(page, e);
 }
示例#10
0
  /**
   * @see
   *     org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
   */
  public void renderHead(IHeaderResponse response) {
    // NOTE JavascriptResourceReference takes care of stripping comments
    // when in deployment (production) mode
    response.renderJavascriptReference(
        new JavascriptResourceReference(DatePicker.class, "dhtmlgoodies_calendar.js"));
    response.renderCSSReference(
        new CompressedResourceReference(DatePicker.class, "dhtmlgoodies_calendar.css"));

    // Set the icons image path
    response.renderOnLoadJavascript(
        "setImagePath(\""
            + RequestCycle.get().urlFor(new ResourceReference(DatePicker.class, "images/"))
            + "\")");
    // Set the language code of the current session
    response.renderOnLoadJavascript(
        "setLanguageCode(\"" + component.getSession().getLocale().getLanguage() + "\")");
  }
示例#11
0
 public String getLayoutUrl(long id, RequestCycle rc) {
   HttpServletRequest req = ((WebRequest) rc.getRequest()).getHttpServletRequest();
   return req.getContextPath() + "/" + BricketApplication.LAYOUT_IMAGE_PATH + "/" + id;
 }
示例#12
0
 public String getThumbnailUrl(long id, RequestCycle rc) {
   HttpServletRequest req = ((WebRequest) rc.getRequest()).getHttpServletRequest();
   return req.getContextPath() + "/" + BricketApplication.THUMBNAIL_IMAGE_PATH + "/" + id;
 }
示例#13
0
 /**
  * Gets the url for the popup button. Users can override to provide their own icon URL.
  *
  * @return the url to use for the popup button/ icon
  */
 protected CharSequence getIconUrl() {
   return RequestCycle.get().urlFor(new ResourceReference(DatePicker.class, "images/icon1.gif"));
 }
  @Override
  public boolean isActive() {

    Page responsePage = RequestCycle.get().getResponsePage();
    return responsePage.contains(getComponent(), true) && getComponent().isVisibleInHierarchy();
  }
示例#15
0
 public static SakaiFacade getFacade() {
   if (facade == null) {
     facade = ((SiteStatsApplication) RequestCycle.get().getApplication()).getFacade();
   }
   return facade;
 }
示例#16
0
 protected CharSequence getDownIconUrl() {
   return RequestCycle.get()
       .urlFor(
           new ResourceReference(WebDataSpinner.class, "images/spinnerDown.gif")); // $NON-NLS-1$
 }
 /**
  * return the current pickwickSession
  *
  * @return the current pickwickSession
  */
 public PickwickSession getPickwickSession() {
   return ((PickwickSession) ((WebRequestCycle) RequestCycle.get()).getSession());
 }
 /**
  * Convenience method to get the http response.
  *
  * @return WebResponse related to the RequestCycle
  */
 protected static WebResponse getWebResponse() {
   return (WebResponse) RequestCycle.get().getResponse();
 }
 /**
  * Convenience method to get the http request.
  *
  * @return WebRequest related to the RequestCycle
  */
 protected static WebRequest getWebRequest() {
   return (WebRequest) RequestCycle.get().getRequest();
 }
示例#20
0
 private void handlePortletParameter() {
   boolean portlet = "true".equals(RequestCycle.get().getRequest().getParameter("portlet"));
   ConstellioSession.get().setPortletMode(portlet);
 }
 public static final void set(RequestCycle requestCycle) {
   RequestCycle.set(requestCycle);
 }