コード例 #1
0
ファイル: NodeExpansion.java プロジェクト: tasfe/lsqt
  /**
   * Get the expansion for the session.
   *
   * @return expansion
   */
  public static NodeExpansion get() {
    NodeExpansion expansion = Session.get().getMetaData(KEY);
    if (expansion == null) {
      expansion = new NodeExpansion();

      Session.get().setMetaData(KEY, expansion);
    }
    return expansion;
  }
コード例 #2
0
 protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
   Args.notNull(url, "url");
   if (info != null && Session.exists() && !Session.get().isSessionInvalidated()) {
     String s = info.toString();
     if (!Strings.isEmpty(s)) {
       QueryParameter parameter = new QueryParameter(s, "");
       url.getQueryParameters().add(parameter);
     }
   }
 }
コード例 #3
0
ファイル: RequestCycle.java プロジェクト: dmt/wicket
  private void onInternalDetach() {
    if (Session.exists()) {
      Session.get().internalDetach();
    }

    if (Application.exists()) {
      IRequestLogger requestLogger = Application.get().getRequestLogger();
      if (requestLogger != null) requestLogger.performLogging();
    }
  }
コード例 #4
0
 @Override
 protected void setValue(OClass entity, String critery, V value) {
   ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
   db.commit();
   try {
     CustomAttributes custom;
     if (OClassPrototyper.CLUSTER_SELECTION.equals(critery)) {
       if (value != null) entity.setClusterSelection(value.toString());
     } else if ((CustomAttributes.ON_CREATE_FIELDS.getName().equals(critery))
         && (custom = CustomAttributes.fromString(critery)) != null) {
       custom.setValue(entity, value != null ? Joiner.on(",").join((List<String>) value) : null);
     } else if ((custom = CustomAttributes.fromString(critery)) != null) {
       custom.setValue(entity, value);
     } else if (OClassPrototyper.SUPER_CLASSES.equals(critery)) {
       if (value != null) entity.setSuperClasses((List<OClass>) value);
     } else {
       PropertyResolver.setValue(
           critery,
           entity,
           value,
           new PropertyResolverConverter(
               Application.get().getConverterLocator(), Session.get().getLocale()));
     }
   } finally {
     db.begin();
   }
 }
コード例 #5
0
 private static Language selectLang() {
   try {
     return Language.valueOf(Session.get().getLocale().getLanguage());
   } catch (IllegalArgumentException e) {
     return null;
   }
 }
コード例 #6
0
 @Override
 protected String load() {
   Locale theLocale = locale;
   if (theLocale == null) {
     theLocale = Session.get().getLocale();
   }
   List<IStringResourceLoader> loaders =
       Application.get().getResourceSettings().getStringResourceLoaders();
   for (IStringResourceLoader loader : loaders) {
     String string =
         loader.loadStringResource(klass, key, theLocale, Session.get().getStyle(), null);
     if (StringUtils.isNotBlank(string)) {
       return string;
     }
   }
   return null;
 }
コード例 #7
0
ファイル: UserRolesAuthorizer.java プロジェクト: phash/bids
 @Override
 public boolean hasAnyRole(Roles roles) {
   RolesSession authSession = (RolesSession) Session.get();
   if (authSession.getAktuellerBenutzer() == null) {
     return false;
   }
   return benutzerService.benutzerHasAnyRoles(authSession.getAktuellerBenutzer());
 }
コード例 #8
0
ファイル: RequestCycle.java プロジェクト: dmt/wicket
  /** Called after request processing is complete, usually takes care of detaching state */
  public void onDetach() {
    try {
      onEndRequest();
      listeners.onEndRequest(this);
    } catch (RuntimeException e) {
      log.error("Exception occurred during onEndRequest", e);
    }

    try {
      requestHandlerExecutor.detach();
    } finally {
      listeners.onDetach(this);
    }

    if (Session.exists()) {
      Session.get().detach();
    }
  }
コード例 #9
0
 /**
  * Adds a comment and shows the success feedback.
  *
  * @param text The text of the comment
  */
 private void createComment(String text) {
   User user = userService.getById(((MySession) Session.get()).getuId());
   if (album == null) {
     commentService.create(user, file, text);
   } else {
     commentService.create(user, album, text);
   }
   info(new StringResourceModel("comments.add.created", this, null).getString());
 }
コード例 #10
0
    public void doFilter(ServletRequest request, ServletResponse response)
        throws IOException, ServletException {
      if (Application.exists() == false) {
        throw new AssertionFailedError("The application is not available!");
      }

      if (Session.exists() == false) {
        throw new AssertionFailedError("The session is not available!");
      }
    }
 @Override
 public String substitutePropertyExpressions(Component component, String string, IModel<?> model) {
   if (string != null && model != null) {
     return PropertyConverterVariableInterpolator.interpolate(
         string,
         model.getObject(),
         Application.get().getConverterLocator(),
         Session.get().getLocale());
   }
   return string;
 }
コード例 #12
0
 @Before
 public void setUp() {
   this.tester = new WicketTester(this.wicketApp);
   ((MySession) Session.get()).setuId(1);
   PageParameters pars = new PageParameters();
   pars.add("album", ALBUM_NAME_EXIST);
   pars.add("user", USER_EMAIL_EXIST);
   Page page = new SharedFiles(pars);
   this.tester.startPage(page);
   tester.assertVisible("signout");
   this.tester.getSession().setLocale(Locale.US);
 }
コード例 #13
0
 /** Get the value via a Java ResourceBundle */
 @Override
 public final String loadStringResource(
     final Class<?> clazz,
     final String key,
     Locale locale,
     final String style,
     final String variation) {
   if (locale == null) {
     locale = Session.exists() ? Session.get().getLocale() : Locale.getDefault();
   }
   try {
     return ResourceBundle.getBundle(bundleName, locale).getString(key);
   } catch (MissingResourceException mrx) {
     try {
       return ResourceBundle.getBundle(
               bundleName, locale, Thread.currentThread().getContextClassLoader())
           .getString(key);
     } catch (MissingResourceException mrx2) {
       return null;
     }
   }
 }
コード例 #14
0
ファイル: HttpsMapper.java プロジェクト: dmt/wicket
    @Override
    public void respond(IRequestCycle requestCycle) {
      String location = url.toString();

      if (location.startsWith("/")) {
        // context-absolute url
        location = requestCycle.getUrlRenderer().renderContextRelativeUrl(location);
      }

      if (config.isPreferStateful()) {
        // we need to persist the session before a redirect to https so the session lasts
        // across both http and https calls.
        Session.get().bind();
      }

      WebResponse response = (WebResponse) requestCycle.getResponse();
      response.sendRedirect(location);
    }
 @Override
 public IRequestHandler onException(RequestCycle cycle, Exception e) {
   EntityManager em = getEntityManager();
   if (em != null) {
     if (em.getTransaction().isActive()) {
       em.getTransaction().rollback();
     }
     if (em.isOpen()) {
       em.close();
     }
   }
   if (e instanceof PageExpiredException) {
     Session.get().error("The page you requested has expired.");
     IPageProvider pageProvider = new PageProvider(new MainPage());
     return new RenderPageRequestHandler(pageProvider);
   }
   return super.onException(cycle, e);
 }
コード例 #16
0
ファイル: EhourWebSession.java プロジェクト: RobKuipers/ehour
  /** Invalidate authenticated user */
  public void signOut() {
    AuthUser user = getAuthUser();

    getSession().clear();

    setAuthentication(null);
    setUserSelectedCriteria(null);

    super.signOut();

    auditService.doAudit(
        new Audit()
            .setAuditActionType(AuditActionType.LOGOUT)
            .setUser(((user != null) ? user.getUser() : null))
            .setUserFullName(((user != null) ? user.getUser().getFullName() : "N/A"))
            .setDate(new Date())
            .setSuccess(Boolean.TRUE));
    Session.get().replaceSession();
  }
コード例 #17
0
 /**
  * Method createShareDataView that shown a list of shared {@link Album}s.
  *
  * @return DataView<{@link Album}> the data view with the list of {@link Album}.
  */
 private DataView<Album> createShareDataView() {
   List<Album> list =
       albumService.getAlbumsSharedWith(((MySession) Session.get()).getuId(), user.getEmail());
   DataView<Album> dataView =
       new DataView<Album>("pageable", new ListDataProvider<Album>(list)) {
         public void populateItem(final Item<Album> item) {
           final Album album = item.getModelObject();
           PageParameters pars = new PageParameters();
           pars.add("user", user.getEmail());
           pars.add("album", album.getName());
           BookmarkablePageLink<Void> bp =
               new BookmarkablePageLink<Void>("link", SharedFiles.class, pars);
           bp.add(new Label("name", album.getName()));
           item.add(bp);
         }
       };
   dataView.setItemsPerPage(ITEMS_PER_PAGE);
   return dataView;
 }
コード例 #18
0
  public LeftNavigationPanel(String id) {
    super(id);
    RepeatingView rv = new RepeatingView("menu");
    add(rv);

    List<MenuItem> menuItems = new ArrayList<MenuItem>();
    menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class));
    menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class));
    menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class));
    menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class));
    menuItems.add(new MenuItem("ListPlayersOfMyClub", ListPlayersOfMyClub.class));
    menuItems.add(new MenuItem("CreateClubPanel", CreateClubPanel.class));

    BBTSession session = (BBTSession) Session.get();
    for (MenuItem i : menuItems) {
      if (checkVisibility(session, i)) {
        WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId());
        rv.add(parent);
        Link lk =
            new Link("link", new Model(i.getDestination())) {

              @Override
              public void onClick() {
                try {
                  Class classe = (Class) getModelObject();
                  Class[] types = {String.class};
                  Constructor constructeur = classe.getConstructor(types);
                  Object[] params = {"businessPanel"};
                  LeftNavigationPanel.this
                      .getParent()
                      .addOrReplace((Component) constructeur.newInstance(params));
                } catch (Exception ex) {
                  Logger.getLogger(LeftNavigationPanel.class.getName()).log(Level.SEVERE, null, ex);
                }
              }
            };
        lk.add(new Label("linkName", i.getCaption()));
        parent.add(lk);
      }
    }
  }
コード例 #19
0
  /**
   * Utility method to convert string values to the corresponding objects.
   *
   * @param clazz the type of the object we want to obtain.
   * @param value the string value we want to convert.
   * @return the object corresponding to the converted string value, or null if value parameter is
   *     null
   */
  public static Object toObject(Class clazz, String value) throws IllegalArgumentException {
    if (value == null) return null;
    // we use the standard Wicket conversion mechanism to obtain the
    // converted value.
    try {
      IConverter converter = Application.get().getConverterLocator().getConverter(clazz);

      return converter.convertToObject(value, Session.get().getLocale());
    } catch (Exception e) {
      WebResponse response = (WebResponse) RequestCycle.get().getResponse();

      response.setStatus(400);
      response.write(
          "Could not find a suitable constructor for value '"
              + value
              + "' of type '"
              + clazz
              + "'");

      return null;
    }
  }
コード例 #20
0
  @Override
  public void renderHead(IHeaderResponse response) {
    super.renderHead(response);

    response.renderJavascriptReference(
        new JavascriptResourceReference(Chart.class, "jquery-1.10.2.min.js"), "jquery");

    ClientProperties clientProperties =
        ((WebClientInfo) ((WebSession) Session.get()).getClientInfo()).getProperties();
    boolean isIE = clientProperties.isBrowserInternetExplorer();
    boolean isLowerThan9 = clientProperties.getBrowserVersionMajor() < 9;
    boolean domreadySupport = !(isIE && isLowerThan9);
    response.renderJavascriptReference("https://www.google.com/jsapi");
    String jsg =
        "	google.load('visualization', '1.2', {\n"
            + "packages : [ 'corechart', 'controls', 'table', 'orgchart']\n"
            + "});";
    response.renderJavascript(jsg, "jsg");
    response.renderJavascriptReference(
        new JavascriptResourceReference(Resolver.class, "bridge.js"));

    generate(container, response, domreadySupport);
  }
コード例 #21
0
ファイル: NodeTranslatorTest.java プロジェクト: srajeev/hippo
  @Test
  public void testObservation() throws Exception {
    Node parent = session.getRootNode().addNode("test", "nt:unstructured");
    Node child = parent.addNode("child", "nt:unstructured");
    child.addMixin("hippo:translated");
    Node translation = child.addNode("hippo:translation", "hippo:translation");
    translation.setProperty("hippo:language", Session.get().getLocale().getLanguage());
    translation.setProperty("hippo:message", "kind");
    session.save();

    NodeTranslator nt = new NodeTranslator(new JcrNodeModel(child));
    final IModel<String> nodeName = nt.getNodeName();
    assertEquals("kind", nodeName.getObject());

    NodeNameObserver observer = new NodeNameObserver(nodeName);
    context.registerService(observer, IObserver.class.getName());

    translation.setProperty("hippo:message", "kindje");
    nodeName.detach();
    home.processEvents();

    assertEquals("kindje", observer.name);
  }
コード例 #22
0
 /**
  * Method createDataView.
  *
  * @return DataView<String>
  */
 private DataView<String> createDataView() {
   final HashSet<String> set = new HashSet<String>();
   final List<ShareInformationAlbums> list =
       new ArrayList<ShareInformationAlbums>(
           shareInformationService.getUserShares(((MySession) Session.get()).getuId()));
   for (ShareInformationAlbums aList : list) {
     set.add(aList.getAlbum().getUser().getEmail());
   }
   final List<String> list1 = new ArrayList<String>(set);
   DataView<String> dataView =
       new DataView<String>("pageable", new ListDataProvider<String>(list1)) {
         public void populateItem(final Item<String> item) {
           final String email = item.getModelObject();
           PageParameters pars = new PageParameters();
           pars.add("user", email);
           BookmarkablePageLink<Void> bp =
               new BookmarkablePageLink<Void>("albums", SharedAlbums.class, pars);
           bp.add(new Label("email", email));
           item.add(bp);
         }
       };
   dataView.setItemsPerPage(ITEMS_PER_PAGE);
   return dataView;
 }
コード例 #23
0
 @Override
 public void setSecurityToken(Serializable securityAccessToken) {
   Session.get().setMetaData(METADATAKEY_AUTH_TOKEN, securityAccessToken);
 }
コード例 #24
0
ファイル: ScalarModel.java プロジェクト: 4DvAnCeBoY/isis
 /** Default implementation looks up from singleton, but can be overridden for testing. */
 protected AuthenticationSession getAuthenticationSession() {
   return ((AuthenticationSessionProvider) Session.get()).getAuthenticationSession();
 }
コード例 #25
0
ファイル: PanelAbstract.java プロジェクト: adamhoward/isis
 /**
  * The underlying {@link AuthenticationSession Isis session} wrapped in the {@link
  * #getWebSession() Wicket session}.
  *
  * @return
  */
 @Override
 public AuthenticationSession getAuthenticationSession() {
   final AuthenticationSessionProvider asa = (AuthenticationSessionProvider) Session.get();
   return asa.getAuthenticationSession();
 }
コード例 #26
0
 public static SyncopeEnduserSession get() {
   return (SyncopeEnduserSession) Session.get();
 }
コード例 #27
0
 public static GitBlitWebSession get() {
   return (GitBlitWebSession) Session.get();
 }
コード例 #28
0
  private void init() {

    add(
        new HeaderContributor(
            new IHeaderContributor() {
              private static final long serialVersionUID = 1L;

              public void renderHead(IHeaderResponse response) {
                response.renderCSSReference(
                    new CompressedResourceReference(
                        WebDataLookupField.class, "servoy_lookupfield.css")); // $NON-NLS-1$
              }
            }) {
          @Override
          public boolean isEnabled(Component component) {
            return !getScriptObject().isReadOnly() && getScriptObject().isEnabled();
          }
        });

    setOutputMarkupPlaceholderTag(true);

    AutoCompleteSettings behSettings = new AutoCompleteSettings();
    behSettings.setMaxHeightInPx(200);
    behSettings.setPreselect(true);
    behSettings.setShowCompleteListOnFocusGain(true);
    behSettings.setAdjustInputWidth(false);

    ClientProperties clp =
        (application.getApplicationType() != IApplication.HEADLESS_CLIENT
            ? ((WebClientInfo) Session.get().getClientInfo()).getProperties()
            : null); // in case of batch processors/jsp, we can't get browser info because UI is not
                     // given by web client components
    if (clp != null && (!clp.isBrowserInternetExplorer() || clp.getBrowserVersionMajor() >= 8)) {
      // smart positioning doesn't work on IE < 8 (probably because of unreliable
      // clientWidth/clientHeight browser element js properties)
      behSettings.setUseSmartPositioning(true);
      behSettings.setUseHideShowCoveredIEFix(
          false); // don't know if the problem this setting is for can still be reproduced (I
                  // couldn't reproduce it)... this is true by default and makes fields in IE and
                  // Opera appear/dissapear if they would be covered by type-ahead popup
    } else {
      behSettings.setUseSmartPositioning(false);
      behSettings.setUseHideShowCoveredIEFix(true);
    }
    behSettings.setThrottleDelay(500);

    IAutoCompleteRenderer<Object> renderer =
        new IAutoCompleteRenderer<Object>() {
          protected String getTextValue(Object object) {
            String str = ""; // $NON-NLS-1$
            if (object instanceof DisplayString) {
              str = object.toString();
            } else if (object != null && !(object instanceof String)) {
              IConverter con = getConverter(object.getClass());
              if (con != null) {
                str = con.convertToString(object, getLocale());
              } else {
                str = object.toString();
              }
            } else if (object != null) {
              str = object.toString();
            }
            if (str == null || str.trim().equals("")) str = "&nbsp;"; // $NON-NLS-1$//$NON-NLS-2$
            return str;
          }

          protected void renderChoice(Object object, Response response, String criteria) {
            if (IValueList.SEPARATOR_DESIGN_VALUE.equals(object)) return;
            String renderedObject = getTextValue(object);
            // escape the markup if it is not html or not just an empty none breaking space (null or
            // empty string object)
            if (!renderedObject.equals("&nbsp;") && !HtmlUtils.hasHtmlTag(renderedObject))
              renderedObject =
                  HtmlUtils.escapeMarkup(
                          renderedObject,
                          true, //$NON-NLS-1$
                          false)
                      .toString();
            response.write(renderedObject);
          }

          /*
           * (non-Javadoc)
           *
           * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#render(java.lang.Object, org.apache.wicket.Response,
           * java.lang.String)
           */
          public void render(Object object, Response response, String criteria) {
            String textValue = getTextValue(object);
            if (textValue == null) {
              throw new IllegalStateException(
                  "A call to textValue(Object) returned an illegal value: null for object: "
                      + object.toString());
            }
            textValue = textValue.replaceAll("\\\"", "&quot;");

            response.write("<li textvalue=\"" + textValue + "\"");
            response.write(">");
            renderChoice(object, response, criteria);
            response.write("</li>");
          }

          /*
           * (non-Javadoc)
           *
           * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#renderHeader(org.apache.wicket.Response)
           */
          @SuppressWarnings("nls")
          public void renderHeader(Response response) {
            StringBuffer listStyle = new StringBuffer();
            listStyle.append("style=\"");

            String fFamily = "Tahoma, Arial, Helvetica, sans-serif";
            String bgColor = "#ffffff";
            String fgColor = "#000000";
            String fSize = TemplateGenerator.DEFAULT_FONT_SIZE + "px";
            String padding = "2px";
            String margin = "0px";
            if (getFont() != null) {
              Font f = getFont();
              if (f != null) {
                if (f.getFamily() != null) {
                  fFamily = f.getFamily();
                  if (fFamily.contains(" ")) fFamily = "'" + fFamily + "'";
                }
                if (f.getName() != null) {
                  String fName = f.getName();
                  if (fName.contains(" ")) fName = "'" + fName + "'";
                  fFamily = fName + "," + fFamily;
                }
                if (f.isBold()) listStyle.append("font-weight:bold; ");
                if (f.isItalic()) listStyle.append("font-style:italic; ");

                fSize = Integer.toString(f.getSize()) + "px";
              }
            }

            if (getListColor() != null && getListColor().getAlpha() == 255) {
              // background shouldn't be transparent
              bgColor = getWebColor(getListColor().getRGB());
            }
            if (getForeground() != null) {
              fgColor = getWebColor(getForeground().getRGB());
            }
            Insets _padding = getPadding();
            if (getPadding() != null)
              padding =
                  _padding.top
                      + "px "
                      + _padding.right
                      + "px "
                      + _padding.bottom
                      + "px "
                      + _padding.left
                      + "px";

            listStyle.append("font-family:" + fFamily + "; ");
            listStyle.append("background-color: " + bgColor + "; ");
            listStyle.append("color: " + fgColor + "; ");
            listStyle.append("font-size:" + fSize + "; ");
            listStyle.append(
                "min-width:" + (getSize().width - 6) + "px; "); // extract padding and border
            listStyle.append("margin: " + margin + "; ");
            listStyle.append("padding: " + padding + "; ");
            listStyle.append(
                "text-align:"
                    + TemplateGenerator.getHorizontalAlignValue(getHorizontalAlignment()));
            listStyle.append("\"");

            response.write("<ul " + listStyle + ">");
          }

          /*
           * (non-Javadoc)
           *
           * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#renderFooter(org.apache.wicket.Response)
           */
          public void renderFooter(Response response) {
            response.write("</ul>"); // $NON-NLS-1$
          }

          /**
           * Returns web color representation of int rgba color by removing the alpha value
           *
           * @param color int representation of rgba color
           * @return web color of form #rrggbb
           */
          private String getWebColor(int color) {
            String webColor = Integer.toHexString(color);
            int startIdx = webColor.length() - 6;
            if (startIdx < 0) startIdx = 0;
            webColor = webColor.substring(startIdx);

            StringBuilder sb = new StringBuilder();
            sb.append('#');
            int nrMissing0 = 6 - webColor.length();
            for (int i = 0; i < nrMissing0; i++) {
              sb.append('0');
            }
            sb.append(webColor);

            return sb.toString();
          }
        };

    AutoCompleteBehavior<Object> beh =
        new AutoCompleteBehavior<Object>(renderer, behSettings) {
          private static final long serialVersionUID = 1L;

          /**
           * @see
           *     org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteBehavior#getChoices(java.lang.String)
           */
          @Override
          protected Iterator<Object> getChoices(String input) {
            String filteredInput = filterInput(input);
            if (changeListener != null) dlm.getValueList().removeListDataListener(changeListener);
            try {
              dlm.fill(parentState, getDataProviderID(), filteredInput, false);
              return dlm.iterator();
            } catch (Exception ex) {
              Debug.error(ex);
            } finally {
              if (changeListener != null) dlm.getValueList().addListDataListener(changeListener);
            }
            return Collections.emptyList().iterator();
          }

          /** filters the input in case of masked input (removes the mask) */
          private String filterInput(String input) {
            String displayFormat = WebDataLookupField.this.parsedFormat.getDisplayFormat();
            if (displayFormat != null
                && displayFormat.length() > 0
                && input.length() == displayFormat.length()) {
              int index = firstBlankSpacePosition(input, displayFormat);
              if (index == -1) return input;
              return input.substring(0, index);
            }
            return input;
          }

          /**
           * Computes the index of the first space char found in the input and is not ' ' nor '*' in
           * the format Example: input '12 - 3 - ' format '## - ## - #' returns 6
           *
           * @param input
           * @param displayFormat
           * @return The index of the first space char found in the input and is not ' ' nor '*' in
           *     the format
           */
          private int firstBlankSpacePosition(String input, String displayFormat) {
            for (int i = 0; i < input.length(); i++) {
              if ((input.charAt(i) == ' ')
                  && (displayFormat.charAt(i) != ' ')
                  && (displayFormat.charAt(i) != '*')) return i;
            }
            return 0;
          }

          /** @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getFailureScript() */
          @Override
          protected CharSequence getFailureScript() {
            return "onAjaxError();"; //$NON-NLS-1$
          }

          /** @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getPreconditionScript() */
          @Override
          protected CharSequence getPreconditionScript() {
            return "onAjaxCall();" + super.getPreconditionScript(); // $NON-NLS-1$
          }

          // need to set this behavior to true (enterHidesWithNoSelection) because otherwise the
          // onKeyDown events
          // or other events for the component with type ahead would be null in Firefox, and would
          // not execute as
          // expected on the other browsers...
          @Override
          public void renderHead(IHeaderResponse response) {
            settings.setShowListOnEmptyInput(
                Boolean.TRUE.equals(
                    UIUtils.getUIProperty(
                        getScriptObject(),
                        application,
                        IApplication.TYPE_AHEAD_SHOW_POPUP_WHEN_EMPTY,
                        Boolean.TRUE)));
            settings.setShowListOnFocusGain(
                Boolean.TRUE.equals(
                    UIUtils.getUIProperty(
                        getScriptObject(),
                        application,
                        IApplication.TYPE_AHEAD_SHOW_POPUP_ON_FOCUS_GAIN,
                        Boolean.TRUE)));
            if (!getScriptObject().isReadOnly() && getScriptObject().isEnabled()) {
              super.renderHead(response);
              response.renderJavascript(
                  "Wicket.AutoCompleteSettings.enterHidesWithNoSelection = true;",
                  "AutocompleteSettingsID"); //$NON-NLS-1$ //$NON-NLS-2$
            }
          }

          /**
           * @see org.apache.wicket.behavior.AbstractBehavior#isEnabled(org.apache.wicket.Component)
           */
          @Override
          public boolean isEnabled(Component component) {
            IFormUIInternal<?> formui = findParent(IFormUIInternal.class);
            if (formui != null && formui.isDesignMode()) {
              return false;
            }
            return super.isEnabled(component) && WebClientSession.get().useAjax();
          }
        };
    add(beh);
  }
コード例 #29
0
 public static NextServerSession get() {
   return (NextServerSession) Session.get();
 }
コード例 #30
0
 @Override
 public Serializable getSecurityToken() {
   return Session.get().getMetaData(METADATAKEY_AUTH_TOKEN);
 }