>From: "Hasan Turksoy" <[EMAIL PROTECTED]> > > hi all, > > it seems there is a buggy case at validator script generation(at > findCommonsValidators method to be exact).. issue is; when i use a component > inside another parent component(that's NOT RENDERED), it's still generating > validator scripts for my child component.. this causes script errors when i > submitted my page... Because, there is a validation script exists for a not > rendered(because parent's not rendered) component. > > To visualize; > // child components won't be rendered > because parent's not rendered > > > client="true" /> > > > > as seen above, my textbox(txt_name) won't be rendered since it's parent > won't be rendered.. But client validator scripts are still being generated > for this field. This causes javascript errors at form submit... > > Should we enter an issue for this case? >
Please create a JIRA ticket for this one. Thanks! > Below is a test method for the case; (necessary methods already in jar's > test package) > /*-------------------------------------------------------------------*/ > public void testScriptNotGeneratedForComponentsInsideNotRenderedParent() > throws Exception { > // find the view root > UIViewRoot root = facesContext.getViewRoot(); > assertNotNull(root); > > UINamingContainer namingContainer = (UINamingContainer) > application.createComponent("javax.faces.NamingContainer"); > > namingContainer.setId(root.createUniqueId()); > root.getChildren().add(root.getChildCount(), namingContainer); > > //create a form 1 > UIComponent form1 = this.createForm("test1", namingContainer); > > > //create a dummy parent panel component > HtmlPanelBox panelbox = createPanelBox("pnl_name", form1); > > //create a dummy component 1 > HtmlInputText component1 = createInputText("txt_name", panelbox); > > //create a required field/server rule > CommonsValidator validator1 = createValidator(component1, > "required", null); > > //create a script component > ValidatorScript script = createValidatorScript(root); > > // render the javascript for the form > StringBuffer htmlSnippet = encode(script); > > System.out.println(htmlSnippet.toString()); > > // search tokens to test for in the javascript > String[] searchTokens = { > "test1_required()", > "this[0] = new Array(\"test1:txt_name\");" > }; > > // none of search tokens exist.. > checkScriptForNotExist(htmlSnippet, searchTokens); > } > > private void checkScriptForNotExist(StringBuffer htmlSnippet, String[] > searchTokens) { > for (int i = 0; i < searchTokens.length; i++) { > Assert.assertFalse("Found: " + searchTokens[i], ( > htmlSnippet.indexOf(searchTokens[i]) != -1)); > } > } > /*-------------------------------------------------------------------*/ > > hope the issue is clear enough... > > best regards, > > > Hasan...