Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Possible Roo bug with Converters?

  1. #11
    Join Date
    Jul 2010
    Posts
    119

    Default

    This helps as well showing the build in spring tags available:


    http://static.springsource.org/sprin...-form.tld.html

    Following the tag namespace in the jspx created by roo

    create.jspx has xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields"

    so field:select is coming from /tags/form/fields/select.tagx

    In select.tagx xmlns:form="http://www.springframework.org/tags/form"

    so <form:select is coming from the spring form tag library.

    The above link is to the documentation for all the spring form tags.

    Hope this helps.

  2. #12
    Join Date
    Jan 2011
    Posts
    8

    Default Thanks!!

    the itemLabel="fullLegalName" works great. I'd actually, like to add the email address if any to make it "Mark Riggins:mark@gmail.com" just in case we have more than one Mark Riggins in the system.

    Also, Now I need to weave my system together. All roo generated is 32 independent forms,
    one for each of my entities. Which is totally unusable for anyone unless they know the schema by heart.

    Is there anyway to generate the forms or integrate the existing forms to do use cases like this:

    1) Add or Update an Address for the current Party that we are updating
    2) Add or Update an Phone number for the current Party that we are updating
    3) Lookup and select one of the Party's Addresses when creating an Order for a Party,
    to set the Order.shippingAddress

    Basically, I'd like a bit more of an explorer interface that allows users to create/edit the
    associated Party children while they are creating/editing the party

  3. #13
    Join Date
    Jan 2011
    Posts
    8

    Default Is itemLabel standard now?

    Nice ref page. I'll bookmark that for sure

    But I had to hand-edit my select.tagx file to add your changes so that it
    would accept the itemLabel argument. However, on the linked page you just sent me
    itemLabel is a standard attribute.

    I downloaded and installed the latest STS 2.5.1.RELEASE about 7 days ago, with roo 1.1.0. Are my tagx files out of date?

    This all came from ~/springsource/tc-server-developer-2.1.0.RELEASE/spring-insight-instance/wtpwebapps/XpertServices/WEB-INF/tags/form/fields/select.tagx

    Is that the right release of tc-server-developer?

    Mark



    Quote Originally Posted by btlife View Post
    This helps as well showing the build in spring tags available:


    http://static.springsource.org/sprin...-form.tld.html

    Following the tag namespace in the jspx created by roo

    create.jspx has xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields"

    so field:select is coming from /tags/form/fields/select.tagx

    In select.tagx xmlns:form="http://www.springframework.org/tags/form"

    so <form:select is coming from the spring form tag library.

    The above link is to the documentation for all the spring form tags.

    Hope this helps.

  4. #14
    Join Date
    Jan 2011
    Posts
    8

    Default Where does select.tagx reside on my system?

    Sorry to be such a newbie pest.

    I'd like to make the edits to select.tagx stick, so that they will become part of any new projects that I create, but I can't seem to find the source file.


    The spring-webmvc-3.0.4.RELEASE.jar file contains a SelectTag.class file.

    Mark

  5. #15
    Join Date
    Jul 2010
    Posts
    119

    Default

    Quote Originally Posted by markriggins View Post
    the itemLabel="fullLegalName" works great. I'd actually, like to add the email address if any to make it "Mark Riggins:mark@gmail.com" just in case we have more than one Mark Riggins in the system.
    One way is to create your own "special" tag, like select2Fields.tagx, and add 2 attributes, field1, and field2, then modifiy the code to concat both the fields in the <form:select>.

    or write your own select.tagx that accepts a list of field name to concat.
    or copy the code from select.tagx into the jspx file and modify it just for the specific case.

    Or on the server side, you could create a transient field that concats the fields and then use that field instead on the itemLabel.

    Code:
    @Transient
    public String fullLegalNameAndAddress() {
    StringBuilder sb = new StringBuilder();
    sb.append(this.fullLegalName).append(" ").append(this.emailAddress);
    return sb.toString();
    }
    Just depends on what makes most since for your project.

  6. #16
    Join Date
    Jul 2010
    Posts
    119

    Default

    Quote Originally Posted by markriggins View Post
    Also, Now I need to weave my system together. All roo generated is 32 independent forms,
    one for each of my entities. Which is totally unusable for anyone unless they know the schema by heart.

    Is there anyway to generate the forms or integrate the existing forms to do use cases like this:

    1) Add or Update an Address for the current Party that we are updating
    2) Add or Update an Phone number for the current Party that we are updating
    3) Lookup and select one of the Party's Addresses when creating an Order for a Party,
    to set the Order.shippingAddress

    Basically, I'd like a bit more of an explorer interface that allows users to create/edit the
    associated Party children while they are creating/editing the party
    There are a lot of options for doing the above. You can add the address fields to the Party form so they can change them at the same time. Same with the phone number.
    You can have the controller return a list of addresses in the model and then tie them to a select.tagx to create a dropdown for the address on the order form.

    You can use Web Flow, with sub-flows the user can choose to add/update addresses, phone numbers, etc.

    You can use ExtJS for a javascript client side solution.

    As for being the starting forms being useless, they are for the end-user, but for the developer you get a fully functional application that allows you to work with data right after roo generates it. Instead of having to create it yourself. I believe Roo's objective is to quickly get a project started, there are way too many variables for Roo to make a production quality application, just using the "schema" the developer provides.

  7. #17
    Join Date
    Jul 2010
    Posts
    119

    Default

    Quote Originally Posted by markriggins View Post
    Sorry to be such a newbie pest.

    I'd like to make the edits to select.tagx stick, so that they will become part of any new projects that I create, but I can't seem to find the source file.


    The spring-webmvc-3.0.4.RELEASE.jar file contains a SelectTag.class file.

    Mark
    select.tagx is generated by Roo and uses the spring tag library <form:select>

    basically select.tagx is a wrapper to the <form:select.

    Roo generates code to get you started, I believe they created the "Roo Tags" in order to give the developer working examples on how tags can be used to create reusable jspx code to make page development faster, and more organzied.

    If you write your own tag you have to copy it into any new projects. Or you can create your own Roo Addon that can add your tags to new projects.

    For example: Create a Roo Addon that holds all your customized tags. Then you would register your addon with roo, and make a command available that would install your tags.

    Code:
    roo>mytagaddon setup
    Of course this would assume that you created a Roo Addon called mytagaddon, and it had an availble command of setup, which copied your tags into the tags folder.

    Since the sourcecode for ROO is available to you, I suppose you could check out the current version, overwrite the select.tagx with your own and build it. Biggest problem with this, is you would have to rebuild Roo every time they release a new version.

    Anyway, just wanted to throw out some options.

  8. #18
    Join Date
    Apr 2010
    Posts
    12

    Default Modified sample to work with Roo generated finders

    I found that I had to add a few extra lines of code to this already, great sample code. Roo-generated finders set the disabledFormBinding parameter to true...therefore here is the modified code to work with this case. I have shown the modified code changes in bold red. I modified btlife's sample as my base.:
    .
    .
    .


    <c:when test="${disableFormBinding}">
    <select id="_${sec_field}_id" name="${sec_field}" multiple="${multiple}">
    <c:forEach items="${items}" var="item">
    <option value="${item}">
    <spring:eval expression="item.${itemLabel}" />
    </option>
    </c:forEach>
    </select>
    </c:when>



    <c:when test="${disableFormBinding}">
    <select id="_${sec_field}_id" name="${sec_field}" multiple="${multiple}">
    <c:forEach items="${items}" var="item">
    <option value="${item[fn:escapeXml(itemValue)]}">
    <spring:eval expression="item.${itemLabel}" />
    </option>
    </c:forEach>
    </select>
    </c:when>

    .
    .
    .


    Quote Originally Posted by btlife View Post
    In case anyone can use it, the lines I added are in bold, everything not in bold, should be exactly what ROO generated:

    Code:
    <jsp:root xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:spring="http://www.springframework.org/tags" xmlns:form="http://www.springframework.org/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
      <jsp:output omit-xml-declaration="yes" />
    
      <jsp:directive.attribute name="id" type="java.lang.String" required="true" description="The identifier for this tag (do not change!)" />
      <jsp:directive.attribute name="field" type="java.lang.String" required="true" description="The field exposed from the form backing object" />
      <jsp:directive.attribute name="path" type="java.lang.String" required="true" description="The relative path to the referenced resource" />
      <jsp:directive.attribute name="items" type="java.util.Collection" required="true" description="The name of the collection displayed in the select box" />
      <jsp:directive.attribute name="label" type="java.lang.String" required="false" description="The label used for this field, will default to a message bundle if not supplied" />
      <jsp:directive.attribute name="itemValue" type="java.lang.String" required="false" description="The identifier used as value in the select box (defaults to 'id' for non enum types)" />
      <jsp:directive.attribute name="itemLabel" type="java.lang.String" required="false" description="The identifier used as label in the select box (defaults to 'id' for non enum types)" />  <jsp:directive.attribute name="required" type="java.lang.Boolean" required="false" description="Indicates if this field is required (default false)" />
      <jsp:directive.attribute name="disabled" type="java.lang.Boolean" required="false" description="Specify if this field should be enabled" />
      <jsp:directive.attribute name="multiple" type="java.lang.Boolean" required="false" description="Specify if the select box should allow multiple selections" />
      <jsp:directive.attribute name="disableFormBinding" type="java.lang.Boolean" required="false" description="Set to true to disable Spring form binding" />
      <jsp:directive.attribute name="render" type="java.lang.Boolean" required="false" description="Indicate if the contents of this tag and all enclosed tags should be rendered (default 'true')" />
      <jsp:directive.attribute name="z" type="java.lang.String" required="false" description="Used for checking if element has been modified (to recalculate simply provide empty string value)" />
    
      <c:if test="${empty render or render}">
    
        <c:if test="${empty disabled}">
          <c:set value="false" var="disabled" />
        </c:if>
    
        <c:if test="${empty label}">
          <spring:message code="label_${fn:toLowerCase(fn:substringAfter(id,'_'))}" var="label" />
        </c:if>
    
        <c:if test="${empty required}">
          <c:set value="false" var="required" />
        </c:if>
    
        <c:if test="${empty multiple}">
          <c:set value="false" var="multiple" />
        </c:if>
        
        <c:set var="sec_field">
          <spring:escapeBody javaScriptEscape="true" >${field}</spring:escapeBody>
        </c:set>
    
        <div id="_${fn:escapeXml(id)}_id">
          <c:choose>
            <c:when test="${not empty items}">
              <label for="_${sec_field}_id">
                <c:out value="${fn:escapeXml(label)}" />
                :
              </label>
              <c:choose>
                <c:when test="${empty itemValue}">
                  <c:choose>
                    <c:when test="${disableFormBinding}">
                      <select id="_${sec_field}_id" name="${sec_field}" multiple="${multiple}">
                        <c:forEach items="${items}" var="item">
                          <option value="${item}">
                            <spring:eval expression="item" />
                          </option>
                        </c:forEach>
                      </select>
                    </c:when>
                    <c:otherwise>
                    	<c:choose>
                    		<c:when test="${not empty itemLabel }">
              			     <form:select id="_${sec_field}_id" items="${items}" path="${sec_field}" itemLabel="${itemLabel }" disabled="${disabled}" multiple="${multiple}" />
                      		</c:when>
                      		<c:otherwise>
                			    <form:select id="_${sec_field}_id" items="${items}" path="${sec_field}" disabled="${disabled}" multiple="${multiple}" />
    			        </c:otherwise>
    		          </c:choose>                  		
                      <br />
                      <form:errors cssClass="errors" id="_${sec_field}_error_id" path="${sec_field}" />
                    </c:otherwise>
                  </c:choose>
                </c:when>
                <c:otherwise>
                  <c:choose>
                    <c:when test="${disableFormBinding}">
                      <select id="_${sec_field}_id" name="${sec_field}" multiple="${multiple}">
                        <c:forEach items="${items}" var="item">
                          <option value="${item[fn:escapeXml(itemValue)]}">
                            <spring:eval expression="item" />
                          </option>
                        </c:forEach>
                      </select>
                    </c:when>
                    <c:otherwise>
                    	<c:choose>
                    		<c:when test="${not empty itemLabel }">
    				    <form:select id="_${sec_field}_id" items="${items}" path="${sec_field}" disabled="${disabled}" multiple="${multiple}" itemValue="${fn:escapeXml(itemValue)}" itemLabel="${fn:escapeXml(itemLabel)}"/>
                      		</c:when>
                      		<c:otherwise>
    				    <form:select id="_${sec_field}_id" items="${items}" path="${sec_field}" disabled="${disabled}" multiple="${multiple}" itemValue="${fn:escapeXml(itemValue)}" />
    				</c:otherwise>
    			</c:choose>                  		
                      <br />
                      <form:errors cssClass="errors" id="_${sec_field}_error_id" path="${sec_field}" />
                    </c:otherwise>
                  </c:choose>
                </c:otherwise>
              </c:choose>
              <c:choose>
                <c:when test="${multiple == false}">
                  <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_${sec_field}_id', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true}})); </script>
                </c:when>
                <!-- disabled due to http://jira.springframework.org/browse/ROO-909 <c:otherwise> <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_${field}_id', widgetType: 'dijit.form.MultiSelect', widgetAttrs : {}})); </script> </c:otherwise> -->
              </c:choose>
            </c:when>
            <c:otherwise>
              <field:reference field="${label}" id="${id}" path="${path}" required="${required}" />
            </c:otherwise>
          </c:choose>
        </div>
        <br />
    
      </c:if>
    </jsp:root>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •