Bonjour,
Moi j'aimerais avoir une petite info sur date.
J'aimerais la mettre au format français, et mettre l'année complète. (Ex : 01/12/2005 et pas 12/1/02)
Avez vous une idée?
Cordialement
Version imprimable
Bonjour,
Moi j'aimerais avoir une petite info sur date.
J'aimerais la mettre au format français, et mettre l'année complète. (Ex : 01/12/2005 et pas 12/1/02)
Avez vous une idée?
Cordialement
Ça se fait à 2 niveaux :
- Il faut préciser le pattern utiliser par la popup (attribut patternKey)
- Il faut également utiliser un formateur (attribut type="nom_du_formateur" et editType="nom_du_formateur")
Le formateur sera référencé dans le fichier struts-layout.properties
par exemple formatter.class = com.obia.safe.struts.LocalFormatter <- nom de la classe qui s'en occupe
La classe de formatage ressemblera à ceci
Dans cet exemple, la balise dans la page jsp resseblerait à çaCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class LocalFormatter extends DispatchFormatter { private static final Logger logger = Logger.getLogger(LocalFormatter.class); public LocalFormatter() { } /** * Formateur pour date */ public String date(Object value, PageContext context) { if (value == null) return ""; Date _value = (Date) value; String format = "dd/MM/yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(_value); } }
Code:
1
2
3
4
5
6
7 ... <layout:date property="ordreTransport.chargementDate" key="Une date" size="10" maxlength="10" patternKey="dd/MM/yyyy" type="date" isRequired="true" editType="date" mode="E,E,I" styleClass="label" /> ...
C'est possible d'avoir une copie du code de référencement dans struts-layout.propertie ?
Cordialement
Pas de problème (ligne rouge)
Citation:
#skin name. Default is the first parameter or the file name (ie Struts-Layout_blue.properties -> blue.css)
skin =
# web directory in which are located the images
directory.images = commons/strutsLayoutConfig
# web directory in which are located the javascrips
directory.config = commons/strutsLayoutConfig
# web directory in which are located the css files. Default is directory.config
directory.css =
# display ot not the null fields in inspect mode
display.null.fields = true
# implementor of the PanelInterface to use
panel.class = fr.improve.struts.taglib.layout.util.BasicPanel
#panel.class = fr.improve.struts.taglib.layout.util.ImagePanel
# implementor of the PopupInterface to use
popup.class = fr.improve.struts.taglib.layout.renderer.BasicPopupRenderer
# implementor of the CollectionInterface to use
collection.class = fr.improve.struts.taglib.layout.util.BasicCollection
collection.class.datagrid = fr.improve.struts.taglib.layout.util.BasicDatagrid
#implementor of the TabsInterface to use.
tabs.class = fr.improve.struts.taglib.layout.util.BasicTabs
# implementor of the FieldInterface to use
field.class = fr.improve.struts.taglib.layout.util.BasicField
# implementor of the TreeviewInterface to use
treeview.class = fr.improve.struts.taglib.layout.util.BasicTreeview
# implementor of the IPagerRenderer to use
pager.class = fr.improve.struts.taglib.layout.renderer.BasicPagerRenderer
# implementor of the ICrumbRenderer to use
crumb.class = fr.improve.struts.taglib.layout.renderer.BasicCrumbRenderer
# implentor of the IButtonImageRenderer to use
button.class = fr.improve.struts.taglib.layout.renderer.BasicImageRenderer
# name of the formatter class
# formatter.class = fr.improve.struts.taglib.layout.formatter.DateFormatter
formatter.class = com.obia.safe.struts.LocalFormatter
# name of the policy class
policy.class =
# name of the formutils class
formutils.class = fr.improve.struts.taglib.layout.util.BasicFormUtils
# name of the image in the image dir to use as the sort pictogram
layout.sort = sort.gif
layout.sort.forward = sort.gif
layout.sort.reverse = sort.gif
layout.sort.label = sort
#name of the image and the label for the pager.
layout.pager.previous.label = <<
layout.pager.previous.img = navigateBackward.gif
layout.pager.next.label = >>
layout.pager.next.img = navigateForward.gif
layout.pager.maxPageItems = 10
layout.pager.maxLinks = 10
layout.pager.displayDirect = false
#name of the image to use as a (un)checked box pictogram and related labels
layout.checkbox.checked =
layout.checkbox.checked.label = checked
layout.checkbox.unchecked =
layout.checkbox.unchecked.label = unchecked
#name of the image to use as a calendar pictogram
layout.calendar = calendar.gif
#if there are both a form and links in a page, follows the link if there are unsaved changes in the form
follow.change = true
#display the error message next to the error field.
error.display = true
#format the error message using Struts properties (errors.header, errors.footer, errors.prefix, errors.suffix)
error.format = false
#set the focus on the first error field.
error.focus = true
#require a valid transaction token to sort collection (this forbids the use of back and refresh buttons)
sort.token.required = false
#keep error messages after a sort
sort.error.keep = true
# use specific rules to sort Strings.
#sort.rules.class = fr.improve.struts.taglib.layout.sort.ParsianSortRules
sort.rules.class = fr.improve.struts.taglib.layout.sort.FrenchSortRules
#include a token in each hyperlink.
link.token.include = true
#number of menus to load at the same time
tree.numberOfMenusLoaded=50
#nested compatbility
nested.compatibility = false
# sort action
sortutil.action = sort.do
# treeview action
treeview.action = treeview.do
# el character.
el.character =$
C'est bizarre je trouve pas ce fichier...
Il est dans quelle arborescence? Il sert à quoi?
Cordialement
Il est dans le jar de struts-layout.
Extrait ce fichier et place-le dans le répertoire src du projet (il sera prioritaire).
Ça fonctionne à la perfection.
Merci !
lol encore moi désolé :oops:
Mais enfaite j'ai un petit soucis encore sur ma date, quand j'affiche ma collection, la date s'affiche comme ça:
1 | 208 | FAVENNEC | 14/07/10 | Expédier | 111
Alors que j'aimerais qu'elle s'affiche : 14/07/2010.
J'ai bien fait tous ce que tu m'as dit....
voila ma collection :
Code:
1
2
3
4
5
6
7
8
9
10 <layout:collection name="dcCommandes" styleClass="DCtableau" > <layout:collectionItemtitle="commande.numcom" property="numcom"/> <layout:collectionItem title="commande.numvente" property="vente.numvente"/> <layout:collectionItem title="commande.nomclient" property="client.nom"/> <layout:collectionItem title="commande.date" property="date"/> <layout:collectionItem title="commande.typeenvoi" property="typeenvoi.description"/> <layout:collectionItem title="commande.montanttotal" property="montanttotal"/> </layout:collection>
bon bha j'ai trouvé, le fichier StrutsLayout.properties n'était pas au bon endroit.
cordialement