Examples of QueryParameter


Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

   {
      UrlMapping mapping = config.getMappingById("validate");
      List<QueryParameter> params = mapping.getQueryParams();
      assertEquals(1, params.size());

      QueryParameter p = params.get(0);
      assertEquals("validator1 validator2", p.getValidatorIds());
      assertEquals("pretty:demo", p.getOnError());
      assertEquals("p", p.getName());
      assertEquals("#{validationBean.validateMethod}", p.getValidatorExpression().getELExpression());

   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

   public static void setUpBeforeClass() throws Exception
   {
      mapping.addAction(new UrlAction("#{bean.action}"));
      mapping.setId("testMapping");
      mapping.setPattern("/test/#{bean.param1}/mapping/#{bean.param2}");
      mapping.addQueryParam(new QueryParameter("key1", "#{bean.qp1}"));
      mapping.addQueryParam(new QueryParameter("key2", "#{bean.qp2}"));

      param1.setName("key1");
      param1.setValue("qp1");
      link.getChildren().add(param1);
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

                        + "' referenced at field '" + queryParamSpec.getFieldName() + "' in class '"
                        + queryParamSpec.getOwnerClass().getName() + "'.");
            }

            // build UrlMapping
            QueryParameter queryParam = new QueryParameter();
            queryParam.setName(queryParamSpec.getName());
            queryParam.setOnError(queryParamSpec.getOnError());
            queryParam.setValidatorIds(join(queryParamSpec.getValidatorIds(), " "));
            queryParam.setOnPostback(queryParamSpec.isOnPostback());

            // optional validator method
            if (!isBlank(queryParamSpec.getValidator()))
            {
               queryParam.setValidatorExpression(new ConstantExpression(queryParamSpec.getValidator()));
            }

            // try to get bean name
            Class<?> clazz = queryParamSpec.getOwnerClass();

            // build expression
            PrettyExpression expression = buildPrettyExpression(clazz, queryParamSpec.getFieldName());
            queryParam.setExpression(expression);

            // trace
            if (log.isTraceEnabled())
            {
               log.trace("Registered query-param '" + queryParam.getName() + "' to '" + expression + "' in mapping: "
                        + mapping.getId());
            }

            // register this action
            mapping.addQueryParam(queryParam);
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

      child.setPathValidators(result);
   }

   private QueryParameter copy(QueryParameter queryParameter)
   {
      QueryParameter result = new QueryParameter();
      result.setExpression(queryParameter.getExpression());
      result.setName(queryParameter.getName());
      result.setOnError(queryParameter.getOnError());
      result.setOnPostback(queryParameter.isOnPostback());
      result.setValidatorExpression(queryParameter.getValidatorExpression());
      result.setValidatorIds(queryParameter.getValidatorIds());
      return result;
   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

               if (value.getClass().isArray())
               {
                  Object[] values = (Object[]) value;
                  for (Object temp : values)
                  {
                     queryParameterValues.add(new QueryParameter(name, temp.toString()));
                  }
               }
               else
               {
                  queryParameterValues.add(new QueryParameter(name, value.toString()));
               }
            }
         }

         result = QueryString.build(queryParameterValues);
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

      }
   }

   private void validateQueryParams(final FacesContext context, final UrlMapping mapping)
   {
      QueryParameter currentParameter = new QueryParameter();
      String currentValidatorId = "";
      try
      {
         List<QueryParameter> params = mapping.getQueryParams();
         for (QueryParameter param : params)
         {
            if (param.hasValidators() || (param.getValidatorExpression() != null))
            {
               currentParameter = param;

               String name = param.getName();
               String el = param.getExpression().getELExpression();

               if (elUtils.getExpectedType(context, el).isArray())
               {
                  String[] values = context.getExternalContext().getRequestParameterValuesMap().get(name);
                  if (values != null)
                  {
                     Object coerced = elUtils.coerceToType(context, el, values);
                     for (String id : param.getValidatorIdList())
                     {
                        currentValidatorId = id;
                        Validator validator = context.getApplication().createValidator(id);
                        validator.validate(context, new NullComponent(), coerced);
                     }
                     if (param.getValidatorExpression() != null)
                     {
                        elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
                                 new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
                                 new Object[] { context, new NullComponent(), coerced });
                     }
                  }
               }
               else
               {
                  String value = context.getExternalContext().getRequestParameterMap().get(name);
                  if (value != null)
                  {
                     Object coerced = elUtils.coerceToType(context, el, value);
                     for (String id : param.getValidatorIdList())
                     {
                        currentValidatorId = id;
                        Validator validator = context.getApplication().createValidator(id);
                        validator.validate(context, new NullComponent(), coerced);
                     }
                     if (param.getValidatorExpression() != null)
                     {
                        elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
                                 new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
                                 new Object[] { context, new NullComponent(), coerced });
                     }
                  }
               }
            }
         }
      }
      catch (ELException e)
      {
         FacesMessage message = new FacesMessage("Could not coerce value [" + currentParameter.getValue()
                  + "] on mappingId [" + mapping.getId() + "] to type ["
                  + elUtils.getExpectedType(context, currentParameter.getExpression().getELExpression()) + "]");
         handleValidationFailure(context, message, currentParameter.getOnError());
      }
      catch (ValidatorException e)
      {
         handleValidationFailure(context, e.getFacesMessage(), currentParameter.getOnError());
      }
      catch (FacesException e)
      {
         FacesMessage message = new FacesMessage("Error occurred invoking validator with id [" + currentValidatorId
                  + "] on mappingId [" + mapping.getId() + "] parameter [" + currentParameter.getName() + "]");
         handleValidationFailure(context, message, currentParameter.getOnError());
      }
   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

      assertEquals(0, mapping.getActions().size());
      assertEquals(1, mapping.getQueryParams().size());
      assertEquals(0, mapping.getPathValidators().size());

      // validate query parameter
      QueryParameter queryParameter = mapping.getQueryParams().get(0);
      assertEquals("myQueryParam", queryParameter.getName());
      assertEquals(true, queryParameter.isOnPostback());

      // validate PrettyExpression
      assertNotNull(queryParameter.getExpression());
      assertEquals(ConstantExpression.class, queryParameter.getExpression().getClass());
      assertEquals("#{myQueryParamBean.someParameter}", queryParameter.getExpression().getELExpression());

   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.config.mapping.QueryParameter

      assertEquals(0, mapping.getActions().size());
      assertEquals(1, mapping.getQueryParams().size());
      assertEquals(0, mapping.getPathValidators().size());

      // validate query parameter
      QueryParameter queryParameter = mapping.getQueryParams().get(0);
      assertEquals("myQueryParam", queryParameter.getName());
      assertEquals(false, queryParameter.isOnPostback());
      assertEquals("#{bean.action}", queryParameter.getOnError());
      assertEquals(2, queryParameter.getValidatorIdList().size());
      assertEquals("myValidator myOtherValidator", queryParameter.getValidatorIds());

      // validate PrettyExpression
      assertNotNull(queryParameter.getExpression());
      assertEquals(ConstantExpression.class, queryParameter.getExpression().getClass());
      assertEquals("#{myQueryParamBean.someParameter}", queryParameter.getExpression().getELExpression());

   }
View Full Code Here

Examples of freenet.client.tools.QueryParameter

          followerNotifierTimer.cancel();
          // The old leader's name
          String originalLeader = Cookies.getCookie(LEADER_NAME);
          if (originalLeader != null) {
            // If there was an old leader, then notifies the server about the takeover
            FreenetRequest.sendRequest(UpdaterConstants.failoverPath, new QueryParameter[] { new QueryParameter("requestId", FreenetJs.requestId),
                new QueryParameter("originalRequestId", originalLeader) });
          }
          // Starts leading
          startLeading();
        }
      }
View Full Code Here

Examples of freenet.client.tools.QueryParameter

  /** This class is a Timer that sends a keepalive message periodically */
  private class KeepaliveTimer extends Timer {
    @Override
    public void run() {
      FreenetRequest.sendRequest(UpdaterConstants.keepalivePath, new QueryParameter("requestId", FreenetJs.requestId), new RequestCallback() {
        @Override
        public void onResponseReceived(Request request, Response response) {
          // If not success, then close the connection
          if (response.getText().compareTo(UpdaterConstants.SUCCESS) != 0) {
            if (firstSuccess == false) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.