• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL tag for setting textfield values using Javascript

 
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
This is my first post. i am confused on How to use EL tag for setting values to my Address Field using getdetails(value) method (i am using javascript here).
Below is my JSP code


here tanneryarray is an arraylist having my tannerydetails(tanneryid, tanneryname, tanneryAddress)
which i collected using Bean Setter method from DB. here is my DAO class
i forwarded this prftanneryDetailslist from servlet to jsp by request.setAttribute. Now i want to set dynamically the value of Address
by selecting Tannery Name. :eek:
Any Help on this will be appreciated.
thanks
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

It's not clear exactly what your question is. You can use an EL expression (not "tag") anywhere in the template text. JSP doesn't know anything about HTML or JavaScript -- to it, it's all just a text blob. So it doesn't matter if you are using EL expressions in HTML, or JavaScript, tr any other template text on the page. The value of the EL will simply be substituted in place.
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Sorry for using Tag. My Question is By Selecting Tannery Name in the Select tag. I am passing the corresponding Tannery Id
to the Javascript Function getDetails. Is there any possibility, by using arraylist tanneryarray, to get the corresponding Tanneryaddress
for the selected Tannery Name.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, no. Remember that JSP operates on the server in order to format an HTML page to send to the browser. Once the response is sent, there can be no more JSP actions as the page is just an HTML page at that point. JavaScript is evaluated on the browser after the response has been sent.

If this is not clear to you, I suggest reading this article.

If you need for your JavaScript to interact with data, what you can do is to use JSP/EL/JSTL to generate JavaScript code that creates these constructs in JavaScript on the client; which your JavaScript code can then access and interact with.
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Bibeault,
It Will be very useful if you give me a code example for below quote..

Bear Bibeault wrote:

If you need for your JavaScript to interact with data, what you can do is to use JSP/EL/JSTL to generate JavaScript code that creates these constructs in JavaScript on the client; which your JavaScript code can then access and interact with.

.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, let's say that you had a scoped variable named whatever that is a String with a value of "Hi there!" that you needed to access in JavaScript. As has already been pointed out, you can't access that Java value once the response is sent to the browser, so you need to create a JavaScript equivalent:

This results in the following being sent to the browser:

With more complex constructs, such as an array or List, you'd use a combination of the JSTL and EL to create a corresponding JavaScript array. For example you'd need to figure out how to use JSTL and EL on a List to end up with markup similar to the following:

I will not write that code for you; you'll need to take a stab at it and post back with any issues you are running into.
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying something like this.


Now this myArray should hold the value of all the tannery address. but in my case it holds only the last value.
I guess there is something i miss. any ideas???
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're not providing enough info to help. How are the lists being used constructed? What's in them? What's being sent to the browser?
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic