0

I need to set the tooltip(title) on the html components.

Here is my code:

In Action class:

  MyForm myForm = (MyForm) form;
  List<String> listOfTitle = new ArrayList<String>();
  listOfTitle.add("AAA");
  listOfTitle.add("BBB");
  listOfTitle.add("CCC");
  listOfTitle.add("DDD");
  myForm.setListOfTitle(listOfTitle);   
  return mapping.findForward("myJsp");

Here the jsp code:

<td>
 <html:text name="myForm" errorStyleClass="validError" property="name"
 size="20" title="${listOfTitle[0]}"/>
</td>
<td>
 <html:text name="myForm" errorStyleClass="validError" property="address"
 size="20" title="${listOfTitle[1]}" /> 
</td>

but listOfTitle[0],listOfTitle[1] gets empty string ("").

please suggest me how i can use the List value using index to display the title on each html components in struts1.x?

Thanks in Advance,

Anand

RockAndRoll
  • 2,247
  • 2
  • 16
  • 35
Anand Kumar
  • 145
  • 1
  • 3
  • 16
  • 1
    You need to add the list to the request. – Stefan Nov 25 '15 at 15:32
  • 1
    No need to add list to the request. He has already set the list in the ActionForm which shall be visible in the Jsp provided it has correct mappings in the struts-config.xml file. – Priyanshu Nov 25 '15 at 19:06

1 Answers1

1

You can access the elements of the list that you have set in the form bean in the title attribute like below.

 <html:text name="myForm" errorStyleClass="validError" property="name"size="20" title='${myForm.listOfTitle[0]}'/>

I hope this answers your question.

Priyanshu
  • 129
  • 8