Announcement Announcement Module
Collapse
No announcement yet.
Generated view isn't displaying data correctly Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generated view isn't displaying data correctly

    I'm using Roo 1.1.0.M3 built from source to test some new functionality.

    In the test app I'm building, I have an int field for the ID, a date field and a string field. I'm able to do all the persistence methods ok, but the list of objects in the generated JSP displays "java.util." where the date is expected and the string field gets cut off after 10 characters, although they're stored fully in the database.

    I'm attaching a screenshot so you can better understand.
    Last edited by pgrimard; Aug 12th, 2010, 03:02 PM.

  • #2
    Can you post a simple Roo script that replicates the problem? Thanks.

    Comment


    • #3
      Just curious if there's a quick way to generate a script from the existing project? I've never used a script in Roo yet, I assume it's just a file with Roo commands. Should be easy enough to replicate from the log.roo file.

      Comment


      • #4
        They are supposed to be cut,

        see the following tagx file (column.tagx) which gets used by list.jspx when you generated a project with latest release of ROO

        Code:
        <c:if test="${empty render or render}">
        
        		<c:if test="${empty label}">
        			<spring:message code="label_${fn:toLowerCase(fn:substringAfter(id,'_'))}" var="label"/>
        		</c:if>
        		<c:choose>
        			<c:when test="${empty columnProperties and empty columnLabels}">
        				<c:set var="columnProperties" value="${property}" scope="request"/>
        				<c:set var="columnLabels" value="${label}" scope="request"/>
                        <c:set var="columnMaxLengths" value="${empty maxLength ? 10 : maxLength}" scope="request"/>
        			</c:when>
        			<c:otherwise>
        				<c:set var="columnProperties" value="${columnProperties},${property}" scope="request"/>
        				<c:set var="columnLabels" value="${columnLabels},${label}" scope="request"/>
                        <c:set var="columnMaxLengths" value="${columnMaxLengths},${empty maxLength ? 10 : maxLength}" scope="request"/>
        			</c:otherwise>
        		</c:choose>
        		
        	</c:if>
        You will have to extend this file to display more than 10 characters and get some hint from display.tagx on how to deal with dates and date patterns.
        Last edited by hatim; Aug 13th, 2010, 01:25 PM.

        Comment


        • #5
          for script files I just do the following on my Linux shell

          Code:
          cat log.roo  | grep -v quit | grep -v hint | grep -v exit | grep -v //

          Comment


          • #6
            Thanks.

            Makes sense for why the title is getting cut down to 10 chars. As for the date, I think it could be because I changed the @DateTimeFormat annotation to @DateTimeFormat(iso = ISO.DATE) since the dates in my database for this entity are stored in ISO format, ie: YYYY-MM-DD. Currently when creating a date field in Roo, the --dateFormat only allows for MEDIUM, NONE or SHORT, but not ISO.DATE.

            Comment


            • #7
              I tried puting the @DateTimeFormat back to @DateTimeFormat(style = "S-") for short format, but that gave me the same result in the list view as @DateTimeFormat(iso = ISO.DATE). The only place where it made a difference to how it looked was when showing or editing the object.

              This is the command I'm using to create my date field:

              field date --fieldName eventDate --type java.util.Calendar --persistenceType JPA_DATE

              Comment


              • #8
                Hmm, I am not sure what is wrong with your setupI use JPA_TIMESTAMP and its working fine

                let me pull latest roo-dev as I have been using M2 release for my recent exploratory work.

                Comment


                • #9
                  I tried JPA_TIMESTAMP as well, but I get a Hibernate exception. My hibernate.hbm2ddl.auto is set to validate, so when using JPA_TIMESTAMP, the exception says "Found: date, expected: timestamp." It only works if I use JPA_DATE.

                  Comment


                  • #10
                    I just did a git pull and used ROO latest dev build

                    then I used the following script
                    Code:
                    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
                    entity --class ~.domain.SomeEntity 
                    field date --fieldName blah --type java.util.Date --persistenceType JPA_DATE
                    controller all --package ~.web
                    And did mvn tomcat:run

                    I can see the date in the list without any issue.

                    Perhaps you may like to regenerate your JSPX files. (delete them or change the filed names)

                    Comment


                    • #11
                      That helped actually. I was using a date with type of java.util.Calendar (personal preference). As soon as I changed it to java.util.Date and repackaged, the display worked fine. Not sure why Calendar type doesn't work, maybe it's a bug? I updated the column.tagx file also to allow for more characters so now my title column displays all the characters.

                      Thanks!

                      Comment

                      Working...
                      X