@Test public void doActionNoParamCtx() throws Exception { final HttpServletRequest rq = this.context.mock(HttpServletRequest.class); final WicketUtil util = new WicketUtil() { @Override public HttpServletRequest getHttpServletRequest() { return rq; } }; this.context.checking(new Expectations() {{ allowing(rq).getContextPath(); will(returnValue("/ctx")); }}); final WicketUrlTemplateFunctionProviderImpl func = new WicketUrlTemplateFunctionProviderImpl(util); assertEquals("/ctx", func.doAction(null, "en", Collections.emptyMap())); assertEquals("/ctx", func.doAction("", "en", Collections.emptyMap())); assertEquals("/ctx/1", func.doAction("1", "en", Collections.emptyMap())); assertEquals("/ctx/1", func.doAction(Collections.singleton("1"), "en", Collections.emptyMap())); assertEquals("/ctx/1/2", func.doAction(Arrays.asList("1", "2"), "en", Collections.emptyMap())); assertEquals("/ctx/1/2/3", func.doAction(Arrays.asList("1", "2", "3"), "en", Collections.emptyMap())); }
@Override public Object doAction(final Object... params) { final StringBuilder url = new StringBuilder(wicketUtil.getHttpServletRequest().getContextPath()); if (params != null && params.length >= 1) { final List sections; if (params[0] instanceof Collection) { sections = new ArrayList((Collection) params[0]); } else if (params[0] != null) { sections = Collections.singletonList(String.valueOf(params[0])); } else { sections = Collections.emptyList(); } final int pLength = this.paramName != null ? this.paramName.length : 0; if (pLength <= sections.size()) { for (int i = 0; i < pLength; i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(this.paramName[i]).append('/').append(sec); } } for (int i = pLength; i < sections.size(); i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(sec); } } } } if (url.length() == 0) { return "/"; } return url.toString(); }
WicketUrlTemplateFunctionProviderImpl implements TemplateProcessor.FunctionProvider { @Override public Object doAction(final Object... params) { final StringBuilder url = new StringBuilder(wicketUtil.getHttpServletRequest().getContextPath()); if (params != null && params.length >= 1) { final List sections; if (params[0] instanceof Collection) { sections = new ArrayList((Collection) params[0]); } else if (params[0] != null) { sections = Collections.singletonList(String.valueOf(params[0])); } else { sections = Collections.emptyList(); } final int pLength = this.paramName != null ? this.paramName.length : 0; if (pLength <= sections.size()) { for (int i = 0; i < pLength; i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(this.paramName[i]).append('/').append(sec); } } for (int i = pLength; i < sections.size(); i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(sec); } } } } if (url.length() == 0) { return "/"; } return url.toString(); } }
WicketUrlTemplateFunctionProviderImpl implements TemplateProcessor.FunctionProvider { @Override public Object doAction(final Object... params) { final StringBuilder url = new StringBuilder(wicketUtil.getHttpServletRequest().getContextPath()); if (params != null && params.length >= 1) { final List sections; if (params[0] instanceof Collection) { sections = new ArrayList((Collection) params[0]); } else if (params[0] != null) { sections = Collections.singletonList(String.valueOf(params[0])); } else { sections = Collections.emptyList(); } final int pLength = this.paramName != null ? this.paramName.length : 0; if (pLength <= sections.size()) { for (int i = 0; i < pLength; i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(this.paramName[i]).append('/').append(sec); } } for (int i = pLength; i < sections.size(); i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(sec); } } } } if (url.length() == 0) { return "/"; } return url.toString(); } WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil);  WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil, final String ... paramName); }
WicketUrlTemplateFunctionProviderImpl implements TemplateProcessor.FunctionProvider { @Override public Object doAction(final Object... params) { final StringBuilder url = new StringBuilder(wicketUtil.getHttpServletRequest().getContextPath()); if (params != null && params.length >= 1) { final List sections; if (params[0] instanceof Collection) { sections = new ArrayList((Collection) params[0]); } else if (params[0] != null) { sections = Collections.singletonList(String.valueOf(params[0])); } else { sections = Collections.emptyList(); } final int pLength = this.paramName != null ? this.paramName.length : 0; if (pLength <= sections.size()) { for (int i = 0; i < pLength; i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(this.paramName[i]).append('/').append(sec); } } for (int i = pLength; i < sections.size(); i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(sec); } } } } if (url.length() == 0) { return "/"; } return url.toString(); } WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil);  WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil, final String ... paramName); @Override Object doAction(final Object... params); }
WicketUrlTemplateFunctionProviderImpl implements TemplateProcessor.FunctionProvider { @Override public Object doAction(final Object... params) { final StringBuilder url = new StringBuilder(wicketUtil.getHttpServletRequest().getContextPath()); if (params != null && params.length >= 1) { final List sections; if (params[0] instanceof Collection) { sections = new ArrayList((Collection) params[0]); } else if (params[0] != null) { sections = Collections.singletonList(String.valueOf(params[0])); } else { sections = Collections.emptyList(); } final int pLength = this.paramName != null ? this.paramName.length : 0; if (pLength <= sections.size()) { for (int i = 0; i < pLength; i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(this.paramName[i]).append('/').append(sec); } } for (int i = pLength; i < sections.size(); i++) { final String sec = (String) sections.get(i); if (StringUtils.isNotBlank(sec)) { url.append('/').append(sec); } } } } if (url.length() == 0) { return "/"; } return url.toString(); } WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil);  WicketUrlTemplateFunctionProviderImpl(final WicketUtil wicketUtil, final String ... paramName); @Override Object doAction(final Object... params);  }