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 creating button using <s:button> - similar to the CSS based button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "creating button using <s:button> - similar to the CSS based button" Watch "creating button using <s:button> - similar to the CSS based button" New topic
Author

creating button using <s:button> - similar to the CSS based button

Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Hi Guys

I am having a JSP with simple form.Here these things are to noted
1. using <a..><span> to create a button using CSS with sliding-door approach. The image can be seen in the attachment.
2. submitting the form on press of Enter key in the form area - the code in the form tag
3. submitting the form after doing a client side check for valid inputs

I want to convert this form with struts tag based form i.e. <s:form..>. However I am facing some problems in
1. converting the button HTML with <s:submit...> tags to create button
2. apply the enter key event capture and submit for there after. (onKeyDown is not a valid attribute for <s:form -tag)
3. can we still do the JavaScript validation

I am not able to figure out, as how to achieve these results. Any help in this regard will be highly appreciated. Thanks in advance guys. >



[Thumbnail for bg_button_blue_a.png]



Programmer Analyst || J2EE web development/design
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you try using "onkeydown"? The CamelCase attribute names aren't really the norm anymore.
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
thanks will give it a try. what about converting <span> based button to <s:submit> and retaining the CSS based display.
and other stuff -

Also here is what I have changed from form to s:form - but on press of Enter key Javascript method in not being called.

what I need to do differently.

any input TIA
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

This is a reasonably complex HTML layout--you're either going to want to create your own theme or just continue doing the form's internals by hand. You might need to tweak the form element names to conform to what S2 expects, but in general the form element names are just the names of the corresponding action properties.
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
great, wat you said about the naming standards is correct (I cross checked with the view source). So following the same here is the new form tag. But still not able to get the desired result. Thanks pal for your efforts in helping me out.


Actually wat is happening here is (when I saw the view page source) The form tag is being rendered as As apparent the js code is being scrapped. How to retain that piece in the resulting form Tag.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Looking in the form-common template it does, indeed, appear to ignore the "onkeydown" attribute (don't know why).

Which version of S2 are you using? At some point the ability to use dynamic tag attributes was added, but I don't recall when that was (or if it's a taglib-wide setting).
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
I am using Tomcat5.5 i.e. JSP2.0. Though I am not sure - if this is what you asked for.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No, I asked what version of S2 (Struts 2) you're using.
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
sorry for being in slumber so long - but was actually not able to post it due to network latency on my side.. I am using Struts 2.0.6 here.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh; that's pretty old--the dynamic attributes was definitely added well after that version.
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
oh ok. thanks ne ways.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating button using <s:button> - similar to the CSS based button
 
Similar Threads
html form,servlet
HTML Submit Button.....URGENT...PLEASE
Combobox is not working in FireFox but it is working in IE.
Ajax code getting null value
How create a virtual keyboard inside a jsp that uses struts layout