Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-02-2008, 06:06 AM
Member
 
Join Date: May 2008
Posts: 1
Pierre Javason is on a distinguished road
Spring binding in jsp
Hey Guys
How's things

This is my first project in the spring framework.
I've checked and read many things but still can't seem to find a solution(which i'm sure exists) to the below problem.

So i'm creating an online exam. I have a Class Question that has question Components and the jsp - exam.jsp

Class:Question with appropriate getter and setter methods
Code:
private List<Component> components;
Class:Component
Code:
private boolean candidateBelieving;
exam.jsp
Code:
<c:forEach items="${question.components}" var="component" varStatus="loopstatus"> <br> <spring:bind path="components[${loopstatus.index}].candidateBelieving"> <input type="radio" name="radio" value="true" <c:if test="${status.value == true}">checked</c:if>/> </spring:bind> <c:out value="${component}"/> </c:forEach>
My problem lies in the jsp code, in that It doesn't bind and set candidateBelieving to true but it used to and here's how.

Previously after reading http://mattfleming.com/node/134 I set name="<cut value='${status.expression}'/>" or something similar(similar because in trying to replicate it I was unable to do so.) The radiobuttons where grouped and data was binding to the command Object(Question) which was good. Until i added in <c:if test="${status.value == true}">checked</c:if> which was setup in case the user clicks the back button provided. At that point each radio button was being treated as a seperate one.

My question is how do i set the property in the spring bind tag if the radio button is ticked, have the radiobuttons as one group and have a radiobutton ticked if it was previously saved?

Is it possible to do this without the spring bind tag?

"Working with Checkboxes
Code:
<c:forEach items="${command.childArray}" var="child" varStatus="loopStatus"> <spring:bind path="command.childArray[${loopStatus.index}].selected"> <input type="hidden" name="_<c:out value="${status.expression}"/>"> <input type="checkbox" name="<c:out value="${status.expression}"/>" value="true" <c:if test="${status.value}">checked</c:if>/> </spring:bind> </c:forEach>
This seems very similar but is still causing problems.

Please help
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-05-2008, 01:21 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
For Each Radio
Your Code

Code:
<c:forEach items="${question.components}" var="component" varStatus="loopstatus"> <br> <spring:bind path="components[${loopstatus.index}].candidateBelieving"> <input type="radio" name="radio" value="true" <c:if test="${status.value == true}">checked</c:if>/> </spring:bind> <c:out value="${component}"/> </c:forEach>

Take this
1. u have used name="radio" , you must be having this in your dataBind. if not then have this. Better change the name to some recognizable name e.g selectedComponent

2. value="true" what does this mean. You should not use "true" here should be some value. you can use counter

3. main thing <c:if test="${status.value eq question.selectedComponent}">checked</c:if>


Hope it get clear.
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Binding javarishi New To Java 3 04-09-2008 12:17 PM
How to use Collection in Spring Java Tip Java Tips 0 03-29-2008 01:45 PM
Some information about spring Albert Web Frameworks 2 07-02-2007 05:08 PM
Spring IDE for Eclipse 2.0 JavaBean Java Announcements 0 06-28-2007 02:26 PM
Spring IDE for Eclipse 2.0 RC1 levent Java Announcements 0 06-12-2007 09:43 AM


All times are GMT +3. The time now is 02:33 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org