简体   繁体   中英

How to set the title on text box using List<String> in struts1.x?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM