RenderUtils { public static String createJQueryBySelector(String elementId, String childSelector) { final StringBuilder jsCall = new StringBuilder(); jsCall.append("jQuery("); jsCall.append("document.getElementById('"); jsCall.append(elementId); jsCall.append("')"); jsCall.append(")"); if (StringUtils.isNotEmpty(childSelector)) { jsCall.append("."); jsCall.append("find('"); jsCall.append(childSelector); jsCall.append("')"); } return jsCall.toString(); }  static void renderJQueryPluginCall(final String elementId, final String pluginFunctionCall,
                                              final ResponseWriter writer, final UIComponent uiComponent); static String createJQueryPluginCall(final String elementId, final String pluginFunctionCall); static String createJQueryPluginCall(final String elementId, final String childSelector, final String pluginFunctionCall); static String createJQueryPluginCall(final String elementId, final String childSelector,
                                                final String pluginFunctionCall, String previousCalls); static String createJQueryBySelector(String elementId, String childSelector); static String createOptionsStringForJQueryPluginCall(Map<String, String> options);  }
@Test public void testCreateJQueryBySelector() throws Exception { Assertions.assertThat(RenderUtils.createJQueryBySelector("test-element-id-1", null)).isEqualTo("jQuery(document.getElementById('test-element-id-1'))"); Assertions.assertThat(RenderUtils.createJQueryBySelector("test-element-id-2", "")).isEqualTo("jQuery(document.getElementById('test-element-id-2'))"); Assertions.assertThat(RenderUtils.createJQueryBySelector("test-element-id-3", "test-child-id")).isEqualTo("jQuery(document.getElementById('test-element-id-3')).find('test-child-id')"); }