This content has been marked as final.
Show 4 replies
-
1. Re: how to test c:foreach
ssilvert Dec 7, 2010 7:30 AM (in response to zhangyy)I'll be glad to help however I can. I see your JSP. What is your problem?
Stan
-
2. Re: how to test c:foreach
zhangyy Dec 7, 2010 9:38 PM (in response to ssilvert)I'll be glad to help however I can. I see your JSP. What is your problem?Stani don't know that how to test c:foreachCould you show me a example?i don't know how to test c:foreach
Could you show me an example?
thanks
-
3. Re: how to test c:foreach
ssilvert Dec 8, 2010 9:09 AM (in response to zhangyy)This might help:
marathons.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <HTML> <f:view> <h1><h:outputText value="Major Marathons" id="title"/></h1> <h:form id="form1"> <table> <tr><th>Marathon</th> <th>Location</th> <th>Select</th></tr> <c:forEach var="marathon" items="#{marathons.list}"> <tr> <td><h:outputText value="#{marathon.name}" /></td> <td><h:outputText value="#{marathon.location}" /></td> <td> <h:commandLink id="marathonSelect" onclick="var foo='bar';" action="#{marathons.select}"> <f:param name="selectedName" value="#{marathon.name}"/> <h:outputText id="selectText" value="Select"/> </h:commandLink> </td> </tr> </c:forEach> </table> <br/><b> <h:outputText value="Selected Marathon: #{marathons.selectedMarathon}"/> </b> </h:form> </f:view>
FacadeAPITest.java
public void testCommandLinkWithParamFromLoopVariable() throws IOException { // test should not run for JSF 1.1 - it uses a loop variable from <c:forEach> if ((Environment.getJSFMajorVersion() == 1) && (Environment.getJSFMinorVersion() < 2)) return; JSFSession jsfSession = new JSFSession("/marathons.faces"); JSFClientSession client = jsfSession.getJSFClientSession(); client.click("marathonSelect"); assertTrue(client.getPageAsText().contains("Selected Marathon: BAA Boston Marathon")); client.click("marathonSelectj_id_3"); assertTrue(client.getPageAsText().contains("Selected Marathon: Flora London Marathon")); client.click("marathonSelectj_id_5"); assertTrue(client.getPageAsText().contains("Selected Marathon: Olympic Marathon")); }
This test is taken from the example here:
Note that the above webapp is dependent on another webapp. So the JSP actually lives in this submodule:
Stan
-
4. Re: how to test c:foreach
zhangyy Dec 16, 2010 1:36 AM (in response to ssilvert)Sorry for late reply, very grateful for your helpSorry for late reply, very grateful for your help