File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Use of Javascript with struts custom tag <html:button> and <html:submit> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Use of Javascript with struts custom tag <html:button> and <html:submit>" Watch "Use of Javascript with struts custom tag <html:button> and <html:submit>" New topic
Author

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

Kishore Sahu
Ranch Hand

Joined: Mar 10, 2009
Posts: 31
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.


Kishore
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
You can write validation rules.Read about validation rules provided by struts
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Sorry about last Post..
You can use onsubmit method & write your javascript function there
Kishore Sahu
Ranch Hand

Joined: Mar 10, 2009
Posts: 31
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

Joined: Mar 10, 2009
Posts: 31
Thanks SuryaKant, for your suggestions.
But please give me a tried example.
Please help me.
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Jan 28, 2008
Posts: 5575

and kishore Welcome to javaranch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 10, 2009
Posts: 31
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Kishore Sahu
Ranch Hand

Joined: Mar 10, 2009
Posts: 31
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Mar 10, 2009
Posts: 31
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

Kishore Sahu wrote:Ok Buddies.,, I got success.


But you can tell us the what new you added, which helps us to learn ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of Javascript with struts custom tag <html:button> and <html:submit>
 
Similar Threads
LookupDispatchAction Question
org.apache.jasper.JasperException (STRUTS 1)
For a single submission on a jsp , two instances are generated in baseaction class
Struts and javascript
"enter key" button focus ?