struts html:button issue

Posted on 2006-04-14
Last Modified: 2008-01-09

   i have a <html:button property="action" .... /> , now if i change the name from "action" to "myaction" , it doesnt work,

  it says "object doesnt support property or method" (  i have an onclick method calling a javascript, that simply checks for a condition and submits the form)

any insight on why its not taking the name "myaction" and only "action"

Question by:letsbedecent
    LVL 11

    Expert Comment

    >>now if i change the name from "action" to "myaction" , it doesnt work,
    what doesn't work? the javascript function with onclick? please post ur javascript code then.
    LVL 2

    Expert Comment

    This is beause you defined default java bean in your page which has methods getAction() setAction(String).
    Make Methods of your form getMyaction() and setMyaction(String) and it should work.
    Or another solution is to supply another java bean to your button like:

    <html:button name="anotherbean" property="action" .... />

    But you should define your bean before using anotherbean.
    LVL 10

    Accepted Solution

    borislavmarkov, your argument is true for any other html components such as text or
    check box (input components) but not true for a button. The property can be *anything*
    for a button. Even an empty one like property="" will work. But, the property itself
    is mandatory.

    LVL 23

    Expert Comment

    letsbedecent is there any property or variable named "action" in your Form Bean.???
    LVL 10

    Expert Comment

    >> letsbedecent is there any property or variable named "action" in your Form Bean.???

    This is pointless as it won't make any difference!

    LVL 23

    Expert Comment

    I will show the point if the author responds.


    Ok radarsh won't that make any difference explain?????

    Author Comment

    actually radarsh is correct i guess., because there is no such property called "action" anywhere in the form. If there was, there is no reason for this confusion.

    But my question to radarsh would then be , why is "myAction" not working ??

    But then i found the answer to this question, because there was actually another button with this property = "myAction". When i changed it to any other name property="abcd" or property="shivaspk" it worked fine.

    So, i guess radarsh is correct. Property is just mandator, doesnt matter what u put there, in case of html:button only.

    I would like to know where radarsh got this info concretely documented. Because i had to do trial-and-error to come to a conclusion. I could not find in any struts document that html:button can have even a blank property attribute !

    Thanks all. (Sorry for the delay in responding !! was enjoying my weekend :p)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Convert ArrayList of custom objects to JSON 4 44
    userCompare  challenge 3 53
    count11 challenge 6 32
    Eclipse Neon and jdk 1.8.0 11 37
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now