• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Load data after click in jsp table cell.  RSS feed

 
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people,
I have in my  jsp page a table, my question is if I can to click in one cell and load data to fields of my jsp page, if I can to do, how I do that.

Thanks and best regards.

Cezar Apulchro.
 
Bartender
Posts: 19993
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You attach a javascript onclick function to the cell. The onclick function uses AJAX to pull the data value from the appserver and enter it into the cell display.
 
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:and load data to fields of my jsp page


Note: by the time it reaches the browser where JavaScript will execute it is no longer a JSP page, rather it is the HTML page that was generated on the server by the JSP.

This is an important distinction as some people mistakenly think that they can still do JSP-ish type things in a page once it is at the browser.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for assistance, I'm studyng javascript to solve this problem, can I leave the question opened until resolve the problem?

Cezar.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
after a little study of javascript and make some researching in internet I did an function to get the content of table cell and load in the value field of the tag input, but  my function don't work. My page is an jsp page and my  value field is an jstl definition like '${xx} '.
Following is my function:

The function getval is not working to load  the collumn of table in the document.
Can you help me?

Thanks.
Cezar.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have an element (and only one element) with the id value of prontu1 on the page?
 
Tim Holloway
Bartender
Posts: 19993
95
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"${xx}" isn't JSTL, it's EL.

And it's not dynamic. Instead the JSP compiler will replace it with the constant text value of "xx" when it renders the page HTML. It won't be addressable as a "$" expression on the client side.

The fact that "$" is an EL token is why the use of "$" notation for jQuery can be hazardous, as the 2 conventions can conflict. When in doubt, use the "jQuery." function format.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes there was more one id prontu1, now is only one. Sorry.
I have one alert to display the content of choice cell command line 21, for instance the alert show me 1111111111 the content of tag td but after execute de comand line 22 he are loading in prontu1 the following: [object HTMLTableCellElement]
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

Cezar.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

I changed my script to jquery, as in javascript I have getting the content of clicked td, how can I put this content in my input tag.
This is my jquery:


and this is my input tag:


I'm trying to load in the value parameter that is a EL parameter to be read by my servlet.

Thanks.
Cezar.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the jQuery .val() method to set the value of an input element.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear, still the same problem.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set breakpoints to find out where things are going awry.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i don't understand what you mean, what is breakpoints? How set this?
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:i don't understand what you mean, what is breakpoints? How set this?



   

See the debugging section of https://coderanch.com/wiki/660075/Javascript-Links.

Trying to write JavaScript without using the debugger is like trying to cut diamonds while blind-folded.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading 'Learning JQuery Fouth Edition' I can't find solution to solve this problem. The value parameter of input tag accept only string, not an number. If I write:

I don't know to solve this problem.

Cezar.
 
Tim Holloway
Bartender
Posts: 19993
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably because HTML itself is nothing but text, with no binary values and that's what you are manipulating.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value of input elements is always a string. Using the type attribute doesn't change that, it just restricts what can be entered.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I solved my problem. I had originally in my jsp an mask to show hour into in my table, I think that this is my problem. This is my last code.
My script:

and my table:

Thanks a lot.
Cezar.
 
Cezar Apulchro
Ranch Hand
Posts: 57
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:Hi guys,
I solved my problem. I had originally in my jsp an mask to show hour into in my table, I think that this is my problem. This is my last code.
My script:

and my table:

Thanks a lot.
Cezar.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!