1

I want to pass arguments from HTML view to Java API in play framework. I've written the following code. What changes should be done to successfully pass the arguments from Html view to API in java controller?.

When i tried passing it as @w.username and @w.email or by keeping '@w.username' or @w.username i've got error.

@import model.User 
@(users: List[User]) 
<html>
    <body>
        <h1>Users</h1>

        <table>
            <thead>
                    <th>User Name</th>
                    <th>Email</th>
                    <th>Status</th>
            </thead>
        <tbody>
            @for(w <- users) {
            <tr>
                <td>@w.username</td>
                <td>@w.email</td>
                <td>@w.status</td>
                <td>            
                    <form action="@routes.UserController.getUser(w.username,w.email)">
                        <input type = "submit" value="View Deatils">
                    </form>
                </td>
            </tr>
            }
        </tbody>
    </table>
</body>
</html>

1 Answer 1

2

It must work just like you wrote it:

@routes.UserController.getUser(w.username,w.email)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, It hasn't worked with the form action. So I've tried anchor tag instead of action then it worked fine. There is no problem with the way I've called the method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.