Announcement Announcement Module
Collapse
No announcement yet.
entity field with reference Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • entity field with reference

    Hi all,
    I have the following code:
    HTML Code:
    entity --class  ~.core.License
    field string --fieldName name --notNull
    field string --fieldName description --notNull --sizeMax 4096
    controller scaffold ~.web.LicenseController
    
    entity --class ~.core.Project
    field string --fieldName projectId --notNull --sizeMax 15 --sizeMin 3
    field reference --class ~.core.Project --fieldName license  --type ~.core.License
    controller scaffold ~.web.ProjectController
    For the project creation form, I get a list box for Licenses where I've got all the details of the object License (e.g. Id: 1, Version: 0, Name: Apache2 License, Description: The license...).
    What is the best way to get the list box that displays only for instance the field name of the object License(e.g. Apache2 License)?

    Thanks in advance,

    CÚdric.

  • #2
    Hi Cedric,

    You could implement 'toString' method in Licence class and return only name.
    Or
    You could change jsp code like this :
    Code:
                <div id="roo_project_customer">
                    <c:if test="${not empty customers}">
                        <label for="_customer">Customer:</label>
                        <form:select cssStyle="width:250px" id="_customer" path="customer">
                            <form:options itemValue="id" itemLabel="name" items="${customers}"/>
                        </form:select>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_customer', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true}})); </script>
                    </c:if>
                </div>
    Cheers,
    Sid

    Comment


    • #3
      Cedric,

      The two ways which Sid described are currently your options. Please note that if you customize the toString() method you need to push it into the Java source code since Roo would reset it next time you start the shell. If you decide to change the jspx file, you need to set @RooWebScaffold(automaticallyMaintainView=false) in the relevant controller since Roo will reset that too.

      We are looking into making this more convenient in future and we would be happy to receive ideas and feedback from you. There is already a Jira ticket for your issue: http://jira.springframework.org/browse/ROO-139.

      HTH,
      Stefan

      Comment


      • #4
        Thanks Sid and Stefan!
        In my case, I would prefer modifying the jspx since the method toString() could be used by other objects.

        Comment

        Working...
        X