• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bean String contains opening and closing td tags

 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody know if this would work...

I have a table being generated in my jsp by using the <c:forEach> and putting my <tr> inside of that. Now, my first <td> tag needs to be created with some mouse over values and a dynamically created link value. What I'm thinking is that I can create the "<td ...all my tag stuff in here...>table value</td>" in my servlet, save it to a bean and then in my jsp I'll have something that looks like this...



The ${rowL.line} would contain the td tags in the string. This should be ok shouldn't it? My IDE is giving me a warning because I don't have the tags written outright in the code. I just wasn't sure if any of you have tried something like this before?
[ December 04, 2007: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The point of JSP is to free you from having to build HTML strings in Java code; a messy and error prone task.
 
Sheriff
Posts: 67746
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
The only thing worse than Java in a JSP is HTML in Java.
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently, I don't see any other way to do what I need to do. However, I am in the process of converting this page and the two popup windows that can be produced from it into MVC. Right now they are my good old jsp mashup. Maybe a new solution will show itself as I keep moving to convert them over.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you want to write the HTML and Javascript in the JSP?
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not that I don't want to write it. I'm in some time constraints and it would be quicker for me to make the HTML string than to try and write the javascript necessary to accomplish my task. Since I have my new search that I just wrote in MVC and my old piece in a code mashup, I am bridging them so that my boss can take a working example to the quarterly meeting on the 17th. I still have a little logic bug to figure out. Once that is done I will then be able to focus are recoding the old piece that I bridged to the new piece using the proper MVC pattern.

I understand your view on this, and I totally agree. But with the time constraints I can't rule out ANY options right now. I'm new to programming java and javascript. I only programmed in javascript in college and that was only for one course. My focus was in C++, python, and assembly. But where I live, the first and only job that popped up was for an AS400 programmer. So that is what I'm doing and our web apps are done in java. So I'm learning all this from scratch. I don't think I'm doing to bad for only working with this stuff for a month or two.

But I digress. Thanks for the help guys. I'll post back if I figure something else out...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can describe exactly what you need to accomplish, it's possible that someone can suggest an approach that both avoids having to create HTML in Java and is quick enough to 'get you to market' in your timeframe.
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I'll try to keep this as brief as possible.

Right now, in my mashup page, I have two tables. They are dynamically built from sql resultsets. I have a javascript that runs at the end of my page loading that does what is called a zebra table. It just takes the odd rows and makes them a greyed color so that it is easier to read. This is what leads to my complication.

In my table, the first cell is clickable. I have it an onClic() event. In the onClick() event I am calling another JS function called LineDetail(var) that excepts a string. That string is just a "get" url that has variables posted in it. All of this is built at the time of the page creation.

There is also a mouseover() event for the table cell as well. The number in the cell is blue text that is underlined to make it look like a link so that the user will know it is clickable. When the user does the mouseover the background color goes to blue and the text color changes to the background color, either grey or white depending on the row. When they mouseout it all changes back to what it just was. Its kind of fancy but adds a great visual look to the page that the inital users group really liked.

Now, the reason for the link in the cell is this... It opens a popup window that contains information about that line. Since there can be many lines they can open up multiple popups, 1 for each line. The reason why we have done it this way is because to view the details of the line I have to make a database call and perform some interpretive logic based on the information in our transaction file to tell what has happened to a particular line. Since this processing can take a few seconds per request we don't load it all at once in collapsable rows, this would take too long.

At any rate, I have to pass 3 pieces of information to the new window. These are line, item, and division. If I build the page without those values there is not way for a javascript function to know what they would be. I could get the line, but there is no way I could get the item number and division code. These are stored in variables at runtime in my code.

What I need to accomplish is a way for me to be able to keep my mouseover/mouseout feature on the table cell while being able to also make the popup window work for the onclick(). I know that the popup will work better once I get everything moved to MVC, I just don't know about building my tables. I was very excited about doing this page without using a form.

My other pages implement multiple forms per page, actually one form per result which is nothing more than a button that posts hidden input fields to the request so that I can retrieve that information in my servlet.

Does this help at all?
[ December 05, 2007: Message edited by: Bryce Martin ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me, something like this would be quicker to write and certainly, easier to maintain than HTML written within Java code.

 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Ben,

Thanks for the reply. I've finished patchworking my two sections of the app. Now I have the next 7 working days to try and move the old part over to MVC. I'm going to try out the code you suggested. Thanks a ton, I'll let you know how I make out.

Thanks
Bryce Martin
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In working on getting a simple example put together I have this piece of code...



There is one problem. The single quotes around my ${} in the td tag cause that string to be taken literally. I can't seem to figure out how to make the value show up between single quotes which is what I need it to do in order for the html to realize what the color value should be. If I take the single quotes away it puts the right values in, but they aren't quoted so it doesn't work.

I'm not sure why this is doing this. ${ is supposed to be reserved and the single quotes should have no effect on them right?


PS. I had to substitute onmouseover with onmooseover, onmouseout with onmoosout, and onclick with onKlick, so that the forum would let me post the message. Smart forum you have here

[ December 05, 2007: Message edited by: Bryce Martin ]
[ December 05, 2007: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never seen this.
What container are you using?
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my page structure looks like this...
html
head
/head
body
div
div--some stuff in here
/div

div
div
table
thead
tbody
c:forEach
tr
td
/td
/tr
/c:forEach
/tbody
/thead
/div
/div

/div
/body
/html



^^^^^I just reread what you wrote and realized what I posted above was useless. I'm using WebSphere Application Server v6.0 which is part of WDSC v.6

I haven't uploaded it to the production machine to test it there on that server. They should act the same.
[ December 05, 2007: Message edited by: Bryce Martin ]
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still haven't been able to figure this out. I've been digging around all morning with reports of this happening anywhere that I can find. Any ideas?
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Bryce,

I think you will need an extra ) at the end of


so it becomes:


Hope this helps, if not: post the html that you get and the html that you want to get.

Herman
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, I figured it out. Although it doesn't make total sense to me right now since it doesn't exactly line up with the EL Specification. But here is what I started with...



As you will notice in the part this.style.color='${status.index % 2 == 0 ? 'white' : '#EEE' }'; that I have single quotes around my EL. My thinking was that the single quote would be put into the html and the value from the EL would plop in between them, since the value needs to be in a single quote.

What was happening is that the single quote was acting as an escape character for the EL and so instead of getting 'white' or '#EEE' in my code I was getting my EL as a literal. I tried all kinds of stuff. I tried double quotes and combinations of double quotes with single quotes and single quoting the single quotes and on and on. Then it hit me. And here is my solution. Make the quotes part of my returned value. So now I have this coded...


This worked like a charm and I've got no problems now.

Like I said, the EL Specification doesn't totally jive here.

You want to look at page 19 of the PDF in this link...

https://jsp.dev.java.net/spec/jsp-2_1-fr-spec-el.pdf

Thanks for all of your help guys, this is just one exception case I think in the Websphere container.
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic