Thank you very much for your suggestions, I have been able to answer you
only now...

The issue, i think, is not related to the availability of the information in
the context, the two variables are already defined in the context. The
problem I have is that the UI label rendering should do a "double rendering"
and it seems not to do so.

I try to better explain (sorry for the message length).

I am working on the file
\applications\product\webapp\catalog\find\miniproductlist.ftl. At lines
46-50 of this file there is the following:
              <#if (listSize > viewSize)>
                  <div>
                    <div>NOTE: Only showing the first ${viewSize} of
${listSize} products. To view the rest, use the Products tab for this
category.</div>
                  </div>
              </#if>

The viewSize and listSize variables are correctly rendered since they are
correctly defined in the context by the miniproductlist.groovy script.
The problem is that this string is english only and I would like to
transform in a standard UiLabel, so I added the following in the
ProductUiLabels.xml file:

    <property key="ProductOnlyShowingFirstN">
        <value xml:lang="en">NOTE: Only showing the first ${viewSize} of
${listSize} products. To view the rest, use the Products tab for this
category.</value>
        <value xml:lang="it">NOTA: Sono elencati solo ${viewSize} di
${listSize} prodotti. Per visualizzare gli altri, usa il pannello Prodotti
di questa categoria.</value>
    </property>

and replaced the above lines in the miniproductlist.ftl file with the
following:

              <#if (listSize > viewSize)>
                  <div>
                    <div>${uiLabelMap.ProductOnlyShowingFirstN}</div>
                  </div>
              </#if>

well, in this case what I get on the screen is the following:

NOTE: Only showing the first ${viewSize} of ${listSize} products. To view
the rest, use the Products tab for this category.

where you can see that the variables are not rendered even if they are
defined in the context.

In my opinion a cyclic rendering should be done on the string until no more
${} are found because all have been rendered.

I think that this is the reason why in many cases labels are divided into
several labels (sometimes of one word only) that are then included in ftl
files to form the whole sentence. Doing this can be a workaround for the
variables rendering (because the variables are not included in the UiLabels
string but in the ftl directly) but we already discussed in the ML that this
should be avoided because it imposes the english words order that is often
different for other languages.

Many thanks,
-Bruno


2008/6/30 Ashish Vijaywargiya <[EMAIL PROTECTED]>:

> Hello Bruno,
> > Unfortunately I see that the parameters ${viewSize} and ${listSize} are
> not
> > rendered as expected but the whole string is displayed as it appears in
> the
> > UiLabel.xml file.
>
> ${viewSize} and ${listSize} means that we should put this values in the
> screen context first then this will be available in the UiLabel.xml
> file.Suppose you are preparing context in the *Screens.xml then you should
> write down something like this :-
>
> <set field="viewSize" value="2"/>
> <set field="listSize" value="2"/>
>
> Or if you would like to put this values in the *.bsh file that is included
> in your *Screens.xml file then you should write down the following code.
>
> context.put("viewSize","2");
> context.put("listSize","2");
>
> If you are keeping your values in the parameters then you should read the
> values from the parameters map inside your UiLabel.xml file.
> In this case you will read by ${parameters.viewSize} &
> ${parameters.listSize}
> For example :-
> <set field="parameters.viewSize" value="2"/>
> <set field="parameters.listSize" value="2"/>
>
> & while putting the values in *.bsh
>
> parameters.put("viewSize","2");
> parameters.put("listSize","2");
>
> You should notice that in the screen definition all the Decorator comes
> after setting this context values and decorator includes(set) the values
> from Property Files.So all the values kept in the context(either in
> parameters or context map) will be available in those *UiLabel.xml files.
>
> And for the localization thing I agree from the Scott's comment.
> So I think I am safe on that point :-)
>
> Please let us know if you still have some more question.
>
> --
> Ashish
>
>
> On Sun, Jun 29, 2008 at 2:25 PM, Scott Gray <[EMAIL PROTECTED]> wrote:
>
> > Hi Bruno
> >
> > I think you're looking for something like this:
> > UtilProperties.getMessage(resource,
> > "AccountingAdditionalShippingChargeForShipment",
> > UtilMisc.toMap("shipmentId", shipmentId), locale);
> >
> > Regard
> >
> > 2008/6/29 Bruno Busco <[EMAIL PROTECTED]>:
> >
> > > Hi,
> > > I am trying to add the following UiLabel that includes some parameters
> > >
> > >    <property key="ProductOnlyShowingFirstN">
> > >        <value xml:lang="en">NOTE: Only showing the first ${viewSize} of
> > > ${listSize} products. To view the rest, use the Products tab for this
> > > category.</value>
> > >        <value xml:lang="it">NOTA: Sono elencati solo ${viewSize} di
> > > ${listSize} prodotti. Per visualizzare gli altri, usa il pannello
> > Prodotti
> > > di questa categoria.</value>
> > >    </property>
> > >
> > > I would like to use it in miniproductlist.ftl to replace an english
> > > constant
> > > text.
> > > Unfortunately I see that the parameters ${viewSize} and ${listSize} are
> > not
> > > rendered as expected but the whole string is displayed as it appears in
> > the
> > > UiLabel.xml file.
> > >
> > > What is the correct way to display parametrized labels?
> > >
> > > Many thanks,
> > > Bruno
> > >
> >
>

Reply via email to