Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Setting Value Attribute of Bean Property in jsp in Struts Application

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In my Struts application I'm trying to set the value attribute of <input> tag in my .jsp. In other words I'm trying to set the initial value of my <input> tag . . .

In regards to the field "ReportDateTime" (next to last line of code shown below) the following code doesn't work. Can someone tell me how to set the value attribute of an <input> tag with a bean property?

Thanks,

Rob




 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please see the ItDoesntWorkIsUseless entry.

What type of input field is it supposed to be? Is the value you're accessing via JSP EL in any scope?
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Here's some more info . . .

This .jsp is just simply displaying the values of a given record from the database. So in the "reportDateTime" field I'm just trying to display the date from the (Oracle) database. However, when the code below is run it shows the string "${defect.reportDateTime}" . . . when what I really want is the actual date value of course. So I guess the issue is how do I get the reportDateTime property of the defect bean to display as the initial value in the <input> tag.

Rob
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running a JSP 2.0 container? Is there a value in scope?
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

There is definitely a value in scope because when I execute the following code I can see it:





However, I don't know how to set this property to the value attribute of the <input> tag . . . still working on this . . .

Rob
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um... why don't you just use the Struts HTML tag, then?

In any case, having the value in a Struts ActionForm, which *is* in scope, isn't the same as having the value *itself* in scope. The value either needs to be in scope, or you need to get it from the action form, if you're not going to put it in scope, or you can just use the convenience tag, which sure seems more reasonable.
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

The problem here is that the <input> tag is part of the dynarch calendar control found here: Dynarch Calendar Control . . . I'm sorry . . . I should've mentioned this in my initial post . . .

So I guess the real issue is how do I set the initial value text (i.e. date as a string) in this control? There has to be a way . . . I just haven't discovered it yet . . .

Also, I'm not sure I understand your "scoping" comments . . . In this case the value is retrieved from the database and put into request scope in the action form with this statement: request.setAttribute("defect", Def);

Rob
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, you never said you were putting it into scope--that's why I asked.

Are you using a JSP 2.0 container?
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Apache Tomcat 5.5 in this case
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you simply display the scoped value? Are you sure that control allows setting the date in the fashion you're trying to set it? A cursory look at the API suggests that it needs to be initialized in the constructor.
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This particular field uses a "popup" calendar . . . the date you set in the constructor is what displays on the calendar . . . and I can do this . . . but what I'm trying to do is to set the text in the textbox that appears next to the button that you press to "popup" the calendar to a string that represents the date coming from the database . . .

I did try this approach . . . basically a javascript function gets called when the page loads. I attemp to pass the date to the javascript function but I get the literal string instead of the actual date . . .

********* Javascript Function *****************




************** Calling code in .jsp ***************




 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect the onload is what you want (although a DOM ready would be safer). If you want the textual representation of the date you'd need to give it that rather than a date object.
 
Robert Wiscup
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Ok . . . I finally figured out something that works . . .

I did this in the Action Class



and this in the .jsp



I really appreciate your help . . .

Now it's time to work on some Tiles . . .

Rob
 
reply
    Bookmark Topic Watch Topic
  • New Topic