Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of Javascript with struts custom tag <html:button> and <html:submit>

 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can somebody help me please?

How we can use Javascript functions to do some operation at client side with the struts taglibs, i.e. <html:submit>, <html:reset>, <html:button> and so on.....???
Please reply me soon....

Thanks.
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write validation rules.Read about validation rules provided by struts
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about last Post..
You can use onsubmit method & write your javascript function there
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried, but it is giving some error in java and JSP.
Can you try a simple alert inside a javascript function, and call it by some event like onClick or onSubmit through a <html:button> or a <html:submit> taglib ???
And please give me that example, whatever you will try, OK.
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks SuryaKant, for your suggestions.
But please give me a tried example.
Please help me.
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer this link
http://struts.apache.org/1.2.x/userGuide/struts-html.html#form

I Cant post any code now as my organization doesn't allow me to do that.I will upload the code after some time
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore Sahu wrote:But please give me a tried example.


you mean , you ask surya to do your work ? search in google , get some sample and make your needs ,if any suggestion you can get help from here(javaranch) . in this way only you can learn i believe
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and kishore Welcome to javaranch
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original poster wrote:I tried, but it is giving some error in java and JSP.

"Some error"? How can anybody help if you don't provide more information than "some error"?!

The JavaScript-oriented onxxx handler attributes all work as they're supposed to, as far as I know.
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Seetharaman.

And I am not asking Surya to do my work..
I am really harassed. because I am new to struts and JSP too.
I don't know much about it. So I asked an example.
Please help me.
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore Sahu wrote:Thanks Seetharaman.

And I am not asking Surya to do my work..
I am really harassed. because I am new to struts and JSP too.
I don't know much about it. So I asked an example.
Please help me.

Have you looked what David said? http://faq.javaranch.com/java/ItDoesntWorkIsUseless

The onClick, onblur, all this JS events will work as they work with non Struts tags, And if you see the JSP code with struts tags, you ll find they are translated into simple html code,
So If you wrote

get resulted into
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yaah Sagar, that's right
but I tried with <html:button> with its onClick attribute, but no output.
I just tried to get an alert through a javascript function, which I called by the event onClick of <html:button> taglib.
So, I am really waiting for you guys, to reply something sensible to me.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't provide the JSP used to create the HTML *or* the JavaScript.

Here's an analogy: my car doesn't work--what's wrong with it?

Here's a start: is the HTML being emitted correctly?
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore Sahu wrote:
So, I am really waiting for you guys, to reply something sensible to me.

provided you post something, which make some sense to us..
Please answer,
Which code has problem, What you're expecting and What you got ?
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Buddies.,, I got success.
I did it. I don't know what was the problem, but I am done by myself.
Anyway, Thanks.
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore Sahu wrote:Ok Buddies.,, I got success.


But you can tell us the what new you added, which helps us to learn ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic