Search code examples
javajspstruts1

how to use struts bean tags in my Custom tags?


I have one custom button tag to handle my functionality, I want some values from the struts bean tags to fulfill my functionality. I am nesting struts tags inside my custom tag.

My code in JSP looks like below.

<button:button  module="MyModule" subModule="MySubModule" aliasType="ButtonType" aliasName="SaveButtonGroup" 
   onClick="addNewPart('<bean:Write property="paymentNumber" name="payment" />','<bean:Write property="transactionId" name="payment" />') </button:button>

But, I am getting the below error while running

weblogic.servlet.jsp.CompilationException: Failed to compile JSP /JSP/cdr/tdsDetails.jsp
tdsDetails.jsp:1:1: The page failed validation from validator: "org.xml.sax.SAXParseException: Attribute "name" was already specified for element "button:button".".
tdsDetails.jsp:308:59: This attribute is not recognized.
onClick="addNewPart('<bean:Write    property="paymentNumber" name="payment" />','<bean:Write    property="transactionId" name="payment" />');"></button:button>

what would be the solution? Thanks in Advance for your help.


Solution

  • You could simplify by ditching the Stuts tags and just using EL:

    <button:button  module="MyModule" subModule="MySubModule" aliasType="ButtonType" aliasName="SaveButtonGroup" 
       onClick="addNewPart('${payment.paymentNumber}','${payment.transactionId}')"> </button:button>