Custom Time Unit

05 Apr '12, 04:14 PM
18,061 Views
No Forum Badges

Goodmornig,

I need a unit to convert milliseconds back to an human understandable format (HH:mm) I know that is possible to do this task with a script unit but, with the need to do this task often, I want to create a custom unit to achieve this.

Is better to start from scratch or to modify the time unit boundled with WR? Any advice?


Buongiorno,

Ho riscontrato il bisogno di una unit che converte millisecondi in un formato leggibile ( HH:mm) so già che questa operazione può essere affrontata con una script unit, ma con la necessità di ripetere questa operazione più volte nel modello, è preferibile implementare una unit dedicata.

E' preferibile modificare la time unit di WR o partire con un una custom unit vuota? Qualche Consiglio?

Thanks / Grazie

 
x 0
Follow
Answer Answer at this question and get points!
Forum Hero - Level 9

Hi,

if you want to obtain the desired result you can prepare a Custom Unit. In this case I suggest you to refer to the source code of the Time Unit and follow the instructions reported in this article of our wiki: Custom Unit Guide

In order to reuse your code with the Script Unit you can write a parametric Groovy/java code and save it to an external file. Then you can refer to it by setting the Script File Property in the General tab of the Properties View. In this way you can refer to the same script code file.

If the data is stored in a database (i.e. timestamp datatype) and you want to show the value with the desired pattern in the rendered page, you can define a subtype of the default pattern. In this way you can set the new type only for the Attribute which require the new pattern. You can refer to the steps described in this post: Format currency

In fact the subtype based on the timestamp datatype could be shown in page with the pattern ""HH.mm"".


Ciao,

per ottenere il risultato desiderato potresti preparare una Custom Unit. In questo caso ti suggerisco di fare riferimento al sorgente della Time Unit e seguire le istruzioni riportate in questo articolo del nostro wiki: Custom Unit Guide

Al fine di riusare il tuo codice con la Script Unit potresti scrivere uno script Groovy/java parametrico e salvarlo come file esterno. Successivamente puoi riferirti a questo file impostando la Proprietà Script File presente nel tab General del Pannello delle Proprietà. In questo modo puoi far rifimento allo stesso file del codice.

Se il dato viene salvato in un database (es: tipo timestamp) e vuoi mostrare il valore con il pattern desiderato nella pagina generata, puoi definire un sottotipo del pattern di default. In questo modo puoi settare il nuovo tipo solo per l'Attributo che richiede il nuovo pattern. Puoi riferirti ai passaggi desritti in questo post: Format currency

Infatti il sottotipo basato sul tipo di dato timestamp può essere mostrato in pagina col pattern ""HH.mm"".

   
x 1
Answer at this question and get points!

Related questions

Ayuda Simple List Component Layout personalizado Button to go on another page Criptare dati sensibili nel database CSV Component with utf8 encoding Custom components Custom descriptors Custom Plug-in Custom Unit and AJAX / SOAP Custom Unit: Difficult example in Guide ... any suggestions? Data flow from a page which is not visible anymore Dynamic link labelling for Custom Unit Encoding Confirm Dialog file analysis then update MySQL database Google Map Unit Guardar Saltos de LINEA How can I add a credit card payment gateway or integrate paypal in my web app logic? how can i open a pdf file using download dialog How complex can Custom Unit output be? How to run the example from Custom Unit Guide? Is there any custom unit store or repository? Do you create/sell custom units? java.lang.NullPointerException More Custom Unit questions: example of Content and Operation Unit? Need help with Landmark Overlays for Google Map Unit. Personalizzazione del login component Problema Invocation Unit Problems with Custom components: Can't get values from output parameters on ok flow. "Run Now" on a job scheduled to run later Selezione sul giorno "Events Planning" Status ProcessInstance and activityInstance in spanish Stored procedure component Twitter Unit - Get Geo location of twitt Usage of the Gantt Unit ¿Visor de imágenes y reproductor de video para la versión 7.2? Image viewer and video player for version 7.2? Web project without initial login form - how to create custom logins? Webratio Add-ons no permite login Webratio don't recognize JSON library WebRatio Platform 7.2 Community Cloud Edition