-
1. Re: No parameter named 'productForm:newIp' is defined in the
ssilvert Dec 11, 2007 5:12 PM (in response to mblondel)Does the Ajax request cause navigation to a new view? If yes, it's probably a bug in JSFUnit.
If not, I would normally still assume that this was a bug in JSFUnit, but I think the problem might be in RichFaces. I think what is happening is that RichFaces is failing to update the component tree of the view.
You can use this static method to print the component tree to standard out and see if the client ID is in the tree:org.jboss.jsfunit.framework.DebugUtil.dumpComponentTree(facesContext);
I probably won't be able to take a closer look until I get home from Javapolis.
Stan -
2. Re: No parameter named 'productForm:newIp' is defined in the
mblondel Dec 12, 2007 2:58 AM (in response to mblondel)Ajax request causes no new navigation (no new view). I stay on the same page.
before the ajax submit the inputText is found but not rendered.
after the Ajax submit, the inputText is now rendered.UIComponent prompt = server.findComponent("form:toto"); assertTrue(prompt.isRendered());
But the webForm is certainly not updated because it is impossible to do this :client.setParameter("form:toto", "titi");
Thanks for your help -
3. Re: No parameter named 'productForm:newIp' is defined in the
ssilvert Dec 12, 2007 4:25 AM (in response to mblondel)So if I understand, before the Ajax request, the component exists in the component tree but is not rendered. After the Ajax request, rendered == true. Correct?
Can you do the dumpComponentTree before and after to verify?
Thanks,
Stan -
4. Re: No parameter named 'productForm:newIp' is defined in the
mblondel Dec 12, 2007 5:09 AM (in response to mblondel)yes the component exists in the component tree before the Ajax Request
JSFClientSession client = ExaWizardNavigationUtils.getStep1JsfClientSession(); JSFServerSession server = new JSFServerSession(client); UIComponent toto = server.findComponent("form:toto"); assertFalse(toto.isRendered()); // Not rendered FacesContext facesContext = FacesContextBridge.getCurrentInstance(); DebugUtil.dumpComponentTree(facesContext); //component exists RichFacesClient richClient = new RichFacesClient(client); client.setParameter("form:product", "productValue"); richClient.ajaxSubmit("a4jsupport"); assertEquals("productValue", server.getManagedBeanValue("#{bean.product}")); DebugUtil.dumpComponentTree(facesContext); toto = server.findComponent("form:toto"); assertTrue(toto.isRendered()); // rendered client.setParameter("form:toto", "totoValue"); // ERREUR !!!!!
the product field in my jsp is an rich:suggestionbox<h:inputText value="#{bean.product}" size="50" id="product" > <a4j:support id="a4jsupport"/> </h:inputText> <rich:suggestionbox for="product" suggestionAction="#{bean.getProducts}" var="result" fetchValue="#{result.productName}" width="200" height="150" minChars="0"> <h:column> <h:outputText value="#{result.productName}" /> </h:column> <a4j:support event="onselect" reRender="toto" /> </rich:suggestionbox> <h:inputText id="toto" rendered="#{! empty bean.product}"/>
-
5. Re: No parameter named 'productForm:newIp' is defined in the
ssilvert Dec 12, 2007 10:12 AM (in response to mblondel)Thanks. I think I know the problem now. I don't think I will be able to fix it until next week when I get home.
http://jira.jboss.com/jira/browse/JSFUNIT-66
Stan -
6. Re: No parameter named 'productForm:newIp' is defined in the
ssilvert Dec 12, 2007 11:13 AM (in response to mblondel)I tried to recreate your problem, but I found that this actually looks like a quirk in RichFaces. To get RichFaces to display a once-unrendered component, you need to surround it with <a4j:outputPanel>.
For instance, the following code will conditionally display rep or foo based on the value of #{textbean.text}<h:inputText id="input_text" size="50" value="#{textbean.text}" > <a4j:support id="a4jsupport" event="onkeyup" reRender="nonfooregion,fooregion"/> </h:inputText> <a4j:outputPanel id="nonfooregion"> <h:outputText value="#{textbean.text}" id="rep" rendered="#{'foo' != textbean.text}"/> </a4j:outputPanel> <a4j:outputPanel id="fooregion"> <h:inputText value="Text is 'foo' !!!!" id="foo" rendered="#{'foo' == textbean.text}"/> </a4j:outputPanel>
You have to rerender the outputPanel which is always rendered. Otherwise, RichFaces doesn't know where to put the newly displayed component.
The following JSFUnit code works for this:JSFClientSession client = new JSFClientSession("/pages/echo.jsf"); Ajax4jsfClient ajaxClient = new Ajax4jsfClient(client); client.setParameter("input_text", "foo"); ajaxClient.ajaxSubmit("a4jsupport"); client.setParameter("foo", "I set it OK");
Does that solve your problem?
Stan