Package org.directwebremoting

Examples of org.directwebremoting.WebContext


        lePanier.ajouter(ep, 1);
        return lePanier;
    }
     public Panier ajouterEpreuveEQAuPanier(int id) throws DAOException {
        // récupération de la DAO dans le contexte de l'application
        WebContext ctx = WebContextFactory.get();
        ServletContext servletContext = ctx.getServletContext();
        IEpreuveDAO dao = (IEpreuveDAO) servletContext.getAttribute("epreuveDAO");

        // récupération de l'objet produit
        Epreuve ep = dao.getEpreuveEQ(id);
View Full Code Here


  /**
   * Calls a script in sibling widget instances within the scope of the current DWR thread
   * @param call the JS method to call on the widget start file
   */
  public static void callSiblings(IWidgetInstance instance, String call){
    WebContext wctx = WebContextFactory.get();
    String currentPage = new SiblingPageNormalizer().getNormalizedPage(instance);
        Collection<?> pages = wctx.getScriptSessionsByPage(currentPage);
      call(pages, call)
  }
View Full Code Here

    }

    public void invoke(Object[] args) {

        // TODO: this only works if its the same thread as request
        WebContext wctx = WebContextFactory.get();
        String currentPage = wctx.getCurrentPage();

        // Get a DWR Util proxy for all the browsers on the current page:
        Collection sessions = wctx.getScriptSessionsByPage(currentPage);
        Util utilAll = new Util(sessions);

        ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);

        // add the reference call to the Util proxy which will cause DWR to
View Full Code Here

  /**
   * Calls a script in sibling widget instances within the scope of the current DWR thread
   * @param call the JS method to call on the widget start file
   */
  public static void callSiblings(IWidgetInstance instance, String call){
    WebContext wctx = WebContextFactory.get();
    String currentPage = new SiblingPageNormalizer().getNormalizedPage(instance);
        Collection<?> pages = wctx.getScriptSessionsByPage(currentPage);
      call(pages, call)
  }
View Full Code Here

  // The only reason to send the call to this servlet is if we somehow wish to
  // update other users.
  @Deprecated
  public String openURL(String url) {
    _logger.debug("openurl called with        "+ url ); //$NON-NLS-1$
    WebContext wctx = WebContextFactory.get();
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("window.open(") //$NON-NLS-1$
        .appendData(url)
        .appendScript(");");        //$NON-NLS-1$
        wctx.getScriptSession().addScript(script);
        return ""; //$NON-NLS-1$
  }
View Full Code Here

  // The only reason to send the call to this servlet is if we somehow wish to
  // update other users.
  @Deprecated
  public String openURL(String url) {
    _logger.debug("openurl called with        "+ url ); //$NON-NLS-1$
    WebContext wctx = WebContextFactory.get();
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("window.open(") //$NON-NLS-1$
        .appendData(url)
        .appendScript(");");        //$NON-NLS-1$
        wctx.getScriptSession().addScript(script);
        return ""; //$NON-NLS-1$
  }
View Full Code Here

        Object object = null;
        String scope = creator.getScope();
        boolean create = false;
        if (!Modifier.isStatic(method.getModifiers()))
        {
            WebContext webcx = WebContextFactory.get();

            // Check the various scopes to see if it is there
            if (scope.equals(Creator.APPLICATION))
            {
                object = webcx.getServletContext().getAttribute(getName());
            }
            else if (scope.equals(Creator.SESSION))
            {
                object = webcx.getSession().getAttribute(getName());
            }
            else if (scope.equals(Creator.SCRIPT))
            {
                object = webcx.getScriptSession().getAttribute(getName());
            }
            else if (scope.equals(Creator.REQUEST))
            {
                object = webcx.getHttpServletRequest().getAttribute(getName());
            }
            // Creator.PAGE scope means we create one every time anyway

            // If we don't have an object then call the creator
            try
            {
                if (object == null)
                {
                    create = true;
                    object = creator.getInstance();
                }
            }
            catch (InstantiationException ex)
            {
                // Allow Jetty RequestRetry exception to propagate to container
                Continuation.rethrowIfContinuation(ex);
                // We should log this regardless of the accessLogLevel.
                log.info("Error creating an instance of the following DWR Creator: " + ((null != creator.getClass()) ? creator.getClass().getName() : "None Specified") + ".", ex);
                throw ex;
            }

            // Remember it for next time
            if (create)
            {
                if (scope.equals(Creator.APPLICATION))
                {
                    // This might also be done at application startup by
                    // DefaultCreatorManager.addCreator(String, Creator)
                    webcx.getServletContext().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.SESSION))
                {
                    webcx.getSession().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.SCRIPT))
                {
                    webcx.getScriptSession().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.REQUEST))
                {
                    webcx.getHttpServletRequest().setAttribute(getName(), object);
                }
                // Creator.PAGE scope means we create one every time anyway
            }
        }
View Full Code Here

   * @param criteria The criteria, such as current page, sortOrder, orderBy etc.
   * @return The updated html for the to be replaced div.
   */
  public String findAllObjects(String criteria, String[] filters) {
   
    WebContext wctx = WebContextFactory.get();
    HttpServletRequest request = wctx.getHttpServletRequest();

    // split results and set values;
    int maxResults = Integer.parseInt(getCriterionValue(criteria, "maxResults", DEFAULT_MAXIMUM_RESULTS));
    int page = Integer.parseInt(getCriterionValue(criteria, displayTagPage, "1"));
    boolean ascending = Integer.parseInt(getCriterionValue(criteria, displayTagSortOrder, "1")) == 1 ? true : false;
    String orderBy = getCriterionValue(criteria, displayTagOrderBy, "id");
    int firstResult = (page - 1) * maxResults;

    int numberOfObjects = getNumberOfObjects(filters);

    // set the episodes on the request so dwr can reload the jsp part.
    request.setAttribute(getObjectsName(), getObjects(firstResult, maxResults, orderBy, ascending, filters));
    request.setAttribute(getNumberOfObjectsName(), numberOfObjects);
    try {
      String html = wctx.forwardToString(viewFragment);
      html = DisplayTagReplacementUtil.updatePagingHtml(html, page, maxResults, numberOfObjects, displayTagPage);
      html = DisplayTagReplacementUtil.updateSortOrderHtml(html, ascending, displayTagSortOrder);
      html = DisplayTagReplacementUtil.updateHtmlLinks(html);
      return html;
    } catch (ServletException e) {
View Full Code Here

    //OK
  }

  public String getUsername() {
    String username = null;
    WebContext webContext = WebContextFactory.get();
    if (webContext != null) {
      HttpServletRequest  req = webContext.getHttpServletRequest();
      if (req != null) {
        //TODO username = req.getRemoteUser();
        HttpSession ss = req.getSession();
        if (ss != null) {
          username = (String)ss.getAttribute("id");
View Full Code Here

  public void setAclService(IAclService aclService_) {
      _aclService = aclService_;
  }

  private HttpSession getHttpSesion() {
    WebContext webContext = WebContextFactory.get();
    if (webContext != null) {
      HttpServletRequest  req = webContext.getHttpServletRequest();
      if (req != null) {
        return req.getSession();
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of org.directwebremoting.WebContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.