0

I don't understand how I can use a finder that takes a parameter to display only the returned data. For example, I have a finder findPrincipalsByUsernameLike(String username) in Principle entity, how can I use this finder in list.jspx to show the user only his/her data?

Principle.java

@RooJavaBean
@RooToString
@RooJpaActiveRecord(table = "security_principals", finders = { "findPrincipalsByUsernameLike" })
public class Principal {

    @NotNull
    @Size(min = 5, max = 50)
    private String username;

    @NotNull
    @Size(min = 5, max = 50)
    private String password;


    private Boolean enabled;
}

users/list.jspx

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:jsp="http://java.sun.com/JSP/Page"
    xmlns:page="urn:jsptagdir:/WEB-INF/tags/form"
    xmlns:table="urn:jsptagdir:/WEB-INF/tags/form/fields" version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8" />
    <jsp:output omit-xml-declaration="yes" />

    <page:find finderName="findPrincipalsByUsernameLike"
        id="ff_edu_gju_syria_model_security_principal"
        path="/principals/find">
        <input data-dojo-props="trim:true" data-dojo-type="dijit/form/TextBox"
            id="toolbarFilter" name="filter" type="text" value="${filter}" />
    </page:find>
    <page:list id="pl_edu_gju_syria_model_security_Principal"
        items="${principals}" z="+E0uiC5dOFGeuICZbYdoS6Nz80o=">
        <table:table data="${principals}"
            id="l_edu_gju_syria_model_security_Principal" path="/security/users"
            z="9ue3QOERNh44QuGQIg9JQzmFKnI=">
            <table:column id="c_edu_gju_syria_model_security_Principal_username"
                property="username" z="REKFqtjHv0gJUiSxe+y1TKytm1w=" />
            <table:column id="c_edu_gju_syria_model_security_Principal_password"
                property="password" z="4khHEC8FhwrPHVFPG7c4s5cP8L4=" />
            <table:column id="c_edu_gju_syria_model_security_Principal_enabled"
                property="enabled" z="boq7MuGPymSQN1CCWrQ8INhy1DM=" />
        </table:table>
    </page:list>
</div>

How can I pass the current username without showing a text area for the user?

MotGJU
  • 117
  • 5

1 Answers1

0

You don't have to send the user as request param.

In the Controller method that handles the request just get the user principal from the request.

Spring Security 3.2 introduced great improvements for easier user detail management, take a look to How to get active user's UserDetails

Community
  • 1
  • 1
eruiz
  • 1,963
  • 1
  • 14
  • 22