Spring MVC handle button event in list

Posted by GigaPr on Stack Overflow See other posts from Stack Overflow or by GigaPr
Published on 2010-05-29T11:35:37Z Indexed on 2010/05/29 11:42 UTC
Read the original article Hit count: 331

Filed under:
|
|
|

Hi,

i created a list of Users

<div class="usersList">           
        <c:forEach items="${users}" var="user">
            <div class="listElementAction">
                <c:out value="${user.id}"/>
            </div>
            <div class="listElement">
                <c:out value="${user.firstName}"/>
            </div>
            <div class="listElement">
                <c:out value="${user.lastName}"/>
            </div>
            <div class="listElement">
                <c:out value="${user.username}"/>
            </div>
            <div class="listElementAction">
                <input type="button" name="Edit" title="Edit" value="Edit" />
            </div>
            <div class="listElementAction">
                <input type="image" src="images/delete.png" name="image" value="${user.id}" alt="Delete" onclick="return confirm('Do you want to delete ${user.username}?')" >
            </div>
            <br />            
            </c:forEach>
        </div>

and my controler looks like this

public class UsersController implements Controller {

    private UserServiceImplementation userServiceImplementation;

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {        

        ModelAndView modelAndView = new ModelAndView("users");                
        modelAndView.addObject("users", this.userServiceImplementation.get());
    return modelAndView;

    }

    public UserServiceImplementation getUserServiceImplementation() {
        return userServiceImplementation;
    }

    public void setUserServiceImplementation(UserServiceImplementation userServiceImplementation) {
        this.userServiceImplementation = userServiceImplementation;
    }


}

How can i handle the delete and edit button event?

© Stack Overflow or respective owner

Related posts about mvc

Related posts about spring