With Ajax, it's not possible since displaytag has no support for ajax. Here is a way of doing this (if I understood what you want to do).
The onclick event handler will point to your Struts action. The action will then get all information from database, populate the list, store it in request.setAttribute
request and return a forward to a jsp page.
From the JSP page, use displaytag to iterate through the list, and display the value using bean:write
tag.
E.g.
This is an example of an anchor tag that uses EL (expression language) pointing to a Struts Action page.
<a href="${pageContext.request.contextPath}/myAction.do?command=DoSomeCommand&userId=<bean:write name="user" property="id" />"><bean:message key="label.my_link" /></a>
The /myAction.do
is declared in struts-config.xml
file as
<action path="/myAction" type="org.apache.struts.action.MyAction" scope="request" parameter="command">
</action>
if you want to use the anchor onclick
event do something like this:
<a onclick="window.location.href='${pageContext.request.contextPath}/myAction.do?command=DoSomeCommand&userId=<bean:write name="user" property="id" />'" href="#"></a>
where ${pageContext.request.contextPath}
means <%= request.getContextPath() %>
alternatively, use the struts <html:link>
tag and it'll render an anchor tag for you.