The objective in this function is that when I enter a value in the toAccountNumber text field and then move off of the text field then the selected option in my facilityCodes drop down would be selected from the ajax call I'm making via the jsp page below. However, it would appear that I am not getting to the method in my backing bean and therefore I'm not getting the value from the backing bean to match to the select option.
I am assuming that my debugger will not execute when executing the jQuery code, is that correct?
After trying my ajax call and could not get my debugger to execute I just put in an alert to see if I could see the value of "data" but there I'm getting a dialog box with the rendered HTML code in it and not the value I should be getting from the bean in the jsp that I'm calling.
My jQuery code is:
The code in my changeSelectedFacilityCode.jsp page:
Any help/direction would be greatly appreciated. Thank you.
Have you verified that this selector, $("#ARTransferForm\\:toAccountNumber"), is returning what you think it is? I'm not convinced that's the correct ID, but I could be wrong. I'd also be nervous about cross-browser compatibility.
I did verify that the selector is indeed returning a value because I did an alert there before modifying my code.
Can you tell me how in my debugger when I call the bean from the changeSelectedFacilityCode.jsp page that I jump over to my code? I put a breakpoint there but I never get there so I cannot see what is actually going to my java code. Hope that makes sense.
I had done an alert right above the $.get in the code below:
I am working on a support issue at the same time that I'm working with you so I've not been able to get Fiddler started unfortunately. I may have to wait until tomorrow to get back with you on this. Sorry for the delay but thanks for your help.
Melinda Savoy wrote:should the break point not be executed in my IDE, if the bean is actually being executed by jQuery?
Should it *not* be executed? I'm not sure how to parse your sentence.
If the code where the breakpoint is set is being executed, and you're in debug mode, the code should stop executing at the breakpoint.
I guess I'm a little confused: what are you expecting as a response from your Ajax call? In the blur() function you're trying to set a select element's value, so wouldn't you want a number (or whatever) back? You're calling a JSP that appears to render an entire form.
You're correct, I misstated the breakpoint which is I would like the code to STOP executing at the line where I have the breakpoint in my java code once I type in the value in my text field and then move off the field. My understanding is once I move off the text field the method being called in my jsp page should execute - maybe I'm misunderstanding the way this should work.
You're also correct in that I DO WANT A VALUE RETURNED TO ME so that that the value in "data" can be used ultimately to SELECT the option from the dropdown id called "facilityCodes". I'm not sure why I'm getting the form returned to me therein lies my question to this forum. Right now I'm just trying to do an alert on the "data" value in the jQuery code so that I can see what is being returned to me from the ajax call.
This is the first time I've used jQuery and therefore the reason for my questions.
I'm working in JSF and I understand that I cannot call a java bean directly from jQuery except through a URL which is why I created this specific JSP page which is in my initial post above. How can I get the value of the bean returned to me?
I did some research on accessing a managed bean directly and it seems to require writing a Servlet that your Ajax request can hit which looks up the bean from the FacesContext and then you would just call methods on that bean from the servlet and return whatever data you wanted. Not the end of the world but not a great solution either. All the other Ajax solutions require you to use more tags like the ajax tag in JSF 2 or a component library like Icefaces that already has it built in. What a mess.
Thanks, Gregg. The more I work with JSF the more I dislike it. I know in Stripes we could just call the action method in the URL for jQuery from our JSP page and life was good.
JSF is definitely not very easy to work with. I'll post to jQuery itself and see if anyone there is working with JSF at all and how to return only the contents of the bean I'm calling and NOT the entire form.
Ew. Isn't there a way to have a managed bean "call through" to a service that could be exposed in a variety of ways? Or is just like any other facade/wrapper/etc. and it's just not designed to be used like that (accessed directly)?
David Newton wrote:Ew. Isn't there a way to have a managed bean "call through" to a service that could be exposed in a variety of ways? Or is just like any other facade/wrapper/etc. and it's just not designed to be used like that (accessed directly)?
There probably is and it's probably hidden deep in the entrails of the tags if anyone took the time to muck through it. I haven't used JSF in years (thank God). If anyone around here knows it is probably Tim Holloway.
Melinda, you might consider asking David's question in the JSF forum. The folks that hang out there will probably be more help when it comes to this kind of info. This thread is really treading between 2 different topics at this point.
I am very new to JSF and my understanding is that I need to call the bean directly from the JSF page via a JSF component. I am trying to do that here as indicated in my initial post but that is returning an entire form in my jQuery code and not just the value of the bean that I'm calling. That is what is tripping me up. I thought it was a jQuery issue.
To be honest, I do not think I'm ever getting to my bean from the call to this JSP page. But without having the debugging capabilities (for whatever reason not executing), I cannot tell what is going on.
That is correct. After doing some more research and getting some more help from the jQuery forum, the rendered HTML form should render the value in a "generated" SPAN. After making some suggested changes to the 2nd JSP page that I'm calling in jQuery, I am now getting an error that says that the managed bean is NOT FOUND.
Once that is fixed then per jQuery I should see the value in my rendered HTML and pick it up from there. We'll see. Thanks.