handling Struts tag, JSTL tag and scriptlet in Ajax.

Hi Experts,

I am working on JSP that consists of Struts tag, JSTL tag and scriptlet with some checkboxes.
Upon clicking any of checkboxes, the entire page reload, but I just want to submit checkbox value and it should hide/display arrow or other check box and change arrow color.
How do I handle these in ajax way? I just want to submit a checkbox value and update part of the JSP page instead of reloading entire page.

<%
  boolean employeeEditable = "true".equals(request.getParameter("noneditable")) ? false : true;
  EmployeeForm[] theEmployees = (EmployeeForm[]) request.getAttribute("employeeView");
  boolean hasEmployees = theEmployees != null && theEmployees.length > 0;
%>

<c:if test="${empty employeeView[0].employee}">						
<html:img pageKey="img.red_arrow" height="10" width="20" border="0"/>					
</c:if>
<c:if test="${not empty employeeView[0].employee}">
<html:img pageKey="img.blue_arrow" height="10" width="20" border="0"/>
</c:if>

<input type="checkbox" class="checkwhite" name="employee" value="Yes" CHECKED />

Open in new window


thanks,
dkim18Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Do you have a link for us to look at?

What javascript library are you using for your AJAX (Jquery)?
0
dkim18Author Commented:
sorry, it is intranet site.
we are using jquery-1.7.2.js and jquery-ui-1.8.21. Is that what you are asking?
0
Julian HansenCommented:
Ok, but I don't see any code for doing an AJAX Call.

Can you posted a page source of your page.

View Source
Copy code and paste to file.
Save and upload file.

That gives us something to look at.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

dkim18Author Commented:
since there are some sensitive information, I had to take a lot of code out.
0
dkim18Author Commented:
0
Julian HansenCommented:
It appears your problem has to do with errors in your markup - your page has a number of errors on it that need to be addressed these include

* Duplicate include of utils.js
* <link> tag inside a <script> tag
* <script> tag inside an open <script> tag
* Unclosed <a> tags - this is what is most likely causing your problem
* Orphan close </form> and </div> tags

Just some of the errors I found on first inspection - the attached (reformatted) file contains HTML comments at the points that need attention.

What is probably happening to cause the page reloads is shown in the following code snippet from the file you posted
            <a href="/vn/medask.do?method=edit&amp;idx=5939" class="link_title">                
              <img src="/images/red_arr.png" height="10" width="20" border="0">
            <span class="checkright">      
              <input type="checkbox"  name="nothing" onclick="javascript:document.location='/vn/medask.do?method=update&xval=No&idx=5939';" class="checkwhite"  />
              No Known&nbsp;Adverse Medication
            </span>

Open in new window

You will notice in the above code your <a> is not being closed. Therefore the <span> that follows it is being included in the <a> so when you click the checkbox it is actually activating the link. You need to close your <a> tags to prevent this from happening.

Word of advice going forward - with HTML the first step when things are not working is to validate your page. You need to make sure that there are no markup errors or script errors lurking on the page that could interfere with the way the page should operate. Once you have eliminated the validation errors you will be better placed to find the cause of any errors you are having.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
@dkim18,

Please refer to grading guidelines here.

Default grade is an A - if you grade a B or C it is expected that you provide a reason as to why you did not grade an A.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.