?
Solved

what is ${status.value} and ${(branch.key)???

Posted on 2006-04-04
9
Medium Priority
?
217 Views
Last Modified: 2010-04-01
i dont know JSTL much;what contents should i set in branches ?what is ${status.value}???


<c:forEach var='branch' items='${branches}'>
                <c:set var="chk" value="false"/>
            <c:forEach var='branch1' varStatus="stat" items='${status.value}'>
                  <c:if test="${(branch.key)==status.value[stat.index]}">       
                      <c:set var="chk" value="checked"/>
                  </c:if>
                </c:forEach>      
      <input type="checkbox" name="${status.expression}"
                              <c:out value="${chk}"/>
                              value="${branch.key}" />${branch.value}
                              <br/>
      </c:forEach>
0
Comment
Question by:chaitu chaitu
  • 5
  • 3
9 Comments
 
LVL 92

Expert Comment

by:objects
ID: 16368279
branches is the name of the collection you want to iterate over in 1st loop
the inner loop will iterate over the value of the value property of the status bean ie. status.getValue()
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16368418
show me an example so that I will understand better
0
 
LVL 92

Expert Comment

by:objects
ID: 16368425
branch.key is the is the value of the key property of the current element for the outer loop
ie.  branch.getKey()
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 92

Expert Comment

by:objects
ID: 16368427
example of what exactly?
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16368908
branches.add("aaa");
branches.add("bbb");

0
 
LVL 92

Expert Comment

by:objects
ID: 16368939
jstl is primarily for accessing bean properties, not for making arbitrary method calls.
That should be handled in your controller.
0
 
LVL 11

Expert Comment

by:Manish
ID: 16369480
objects,
   Any good JSTL tutorial or ref?
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16369656
getting exception in jsp code....

            <c:forEach var='branch' items='${branches}'>
                <c:set var="chk" value="false"/>
            <c:forEach var='branch1' varStatus="stat" items='${status.value}'>
      <c:if test="${(branch.key)==status.value[stat.index]}">       
          <c:set var="chk" value="checked"/>
      </c:if>
          </c:forEach>      
      <input type="checkbox" name="${status.expression}"
                              <c:out value="${chk}"/>
                              <c:out value="${branch.key}" />${branch.value}
                              <br/>
      </c:forEach>

javax.servlet.ServletException: Unable to find a value for "key" in object of class "java.lang.String" using operator "."


controller
*********

      branches.add("1111");
            branches.add("2222");
            branches.add("3333");

String[] user=  (String[])branches.toArray(new String[0]);

        request.setAttribute("branches",branches);
0
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 16369672
branches is a list of strings, so branch will be a String

and here:

     <c:if test="${(branch.key)==status.value[stat.index]}">      

you try to access the key property of branch which does not exist
ie. String does not have a method getKey()
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question