Giter VIP home page Giter VIP logo

Comments (3)

mickaelbaron avatar mickaelbaron commented on June 15, 2024 1

Hi Angelo,

Thanks for your response. You're right is about a Velocity template comment => off topic, sorry.

I don't think is a bad idea to format date inside the Velocity template. In fact, this aspect concerns the UI layer and it's the purpose of a template, isn't it ?

Any way, for my problem, here is my solution

A declare a DateTool instance

context.put("date", new DateTool());

DateTool is a class from Velocity-tools-x.x.jar. You need to add this dependency into your pom.xml.

Into the Velocity template (in fact the docx template), i change for that

$date.format("dd-MM-yyyy", $incoming.birthday)

Mickael

from xdocreport.

angelozerr avatar angelozerr commented on June 15, 2024

@mickaelbaron your issue is about Velocity template engien uses. To be honnest with you I have never played with date & Velocity. You can find a sample at http://www.java2s.com/Code/Java/Velocity/HowtouseDateinVelocity.htm

IMHO I think it's a bad idea to format date inside docx template, because mergefield write is more complex.

from xdocreport.

angelozerr avatar angelozerr commented on June 15, 2024

I don't think is a bad idea to format date inside the Velocity template. In fact, this aspect concerns the UI layer and it's the purpose of a template, isn't it ?

I agree with you, docx template is the UI Layer. When you use Velocity to generate HTML, I agree with you, date must be formatted inside the template. In this case, the HTML template is written by a developer.

But in the case of docx template, I think formatting must be done not inside docx template because :

  • template can be created by a non developer (like secratary), so field name must be simple.
  • when mergefield is too long, MS Word doesnt displays the full name of the mergefield. So it's a little hard to read the field name.
  • the XDocReport Macro https://code.google.com/p/xdocreport/wiki/DocxDesignReportMacro works with simple field name.

from xdocreport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.