Struts2 Action: Reload the same page with another parameter

A client of mine asked for a way to search employees, not just filter them using the first letter of the family name.
I just provided a textfield and a link changing according to the textfield content: 

<script type=”text/javascript”>
function searchEmployee()
{
    document.getElementById(‘filter’).href
        = “<s:url value=”/Employees” />” + “?filter=”
        + encodeURIComponent(document.getElementById(‘firstName’).value);
}
</script>

<input type=”text” id=”firstName” value=”” onblur=”searchEmployee();” />
<a id=”filter” href=”<s:url action=”Employees” />” title=”Search by family name”>
    Enter the first letters of the employee family name
</a>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: