Hi, How do I fill in the current username in to a hidden field so I can limit access to those records?
I've been searching for a while and I found this code that should grab the username. I found no specific answer so I'm asking here.
currently I'm using a drop down list to select the sales person.Code:@RequestMapping(method = RequestMethod.GET) public ModelAndView showResults(final HttpServletRequest request, Principal principal) { final String currentUser = principal.getName();
my src/domain/SalesOrder.java:
My src/web/SalesOrderController.Code://TODO: Auto-populate Sales Tech field with user id @NotNull @ManyToOne private SalesTechnician salesTech;
and the relevant line from create.jspxCode:import com.aaceglass.domain.SalesOrder; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @RequestMapping("/salesorders") @Controller @RooWebScaffold(path = "salesorders", formBackingObject = SalesOrder.class, delete = false, update = false) @RooWebFinder public class SalesOrderController { }
Code:<!-- TODO: Change this field to Hidden, and insert logged in user name --> <field:select field="salesTech" id="c_com_aaceglass_domain_SalesOrder_salesTech" itemValue="id" items="${salestechnicians}" path="/salestechnicians" required="true" z="5NC$
Then I have ROLE_SALES, ROLE_CSR.
ROLE_SALES can only see their own records. ROLE_CSR needs to be able to see all records.
I tried to make a finder, but when I click on it, it does the same thing as if I just clicked create. (full blank submission form, not a list)
findSalesOrdersBySalesTech.jspx
Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <div xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"> <jsp:directive.page contentType="text/html;charset=UTF-8"/> <jsp:output omit-xml-declaration="yes"/> <form:find finderName="BySalesTech" id="ff_com_aaceglass_domain_SalesOrder" path="/salesorders" z="eYmADvOzqK/rCl9Rg3xkazCQJg8="> <field:select disableFormBinding="true" field="salesTech" id="f_com_aaceglass_domain_SalesOrder_salesTech" itemValue="id" items="${salestechnicians}" path="/salestechnicia$ </form:find> </div>


Reply With Quote
