You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Olivier Billard <ol...@laposte.net> on 2005/01/27 11:42:23 UTC

Include pipeline content in another servlet

Hi cocooners,

For some design constrainst, I would like from another servlet, to tell Cocoon to output files.
A wrapper has been made around the CocoonServlet to redirect servlet outputstream to a file. That's the existing part.
Then in a servlet I would like to tell Cocoon to output a file here is a snippet :

request.getRequestDispatcher(cocoonPipeline).include(request, response);

The problem is that Cocoon bases request processing over the request.getServletPath() to get the URI, and this don't change from 
the request that originally called the calling servlet...

So is there a better and working method to call file outputting to the Cocoon servlet from another servlet ?

Thanks,

--
Olivier Billard


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Include pipeline content in another servlet

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Olivier Billard wrote:
> Thanks for your answer Leszek,
> 
> Unfortunately, the Cocoon pipes are working with informations stored in 
> session or request attributes...
> How do you handle these ? It would be too much work to change this to 
> use only request params...
have a look at: 
/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
Project Manager                                    MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Vilya Harvey <vi...@gmail.com>.
Gunter D'Hondt wrote:

>and what with the woody field convertors? for example i've got the 
>following widget declaration:
>  <wd:output id="price">
>    <wd:label/>
>    <wd:datatype base="decimal">
>      <wd:convertor variant="number">
>        <wd:patterns>
>          <wd:pattern>#0.00</wd:pattern>
>        </wd:patterns>
>      </wd:convertor>
>    </wd:datatype>
>  </wd:output>
>  
>
I don't know if things have changed in this regard between Woody and 
CForms, but in CForms at least you can provide multiple pattern tags 
inside the patterns element. Each of them has a locale="..." attribute 
to say which locale that format should be used for.The most specific one 
is always used. If there is a pattern element without a locale 
attribute, that's used as the default if nothing more specific matches.

See the documentation at 
http://cocoon.apache.org/2.1/userdocs/forms/datatypes.html#Convertors 
for more information.

Hope that helps,
Vil.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


[SOLVED] Re: decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
Indeed, with nl_BE it didn't work but it does with fr_FR !!!

now the Woody part is solved (it uses the fr_FR) and for the xsl I used 
the following:

<xsl:decimal-format name="belgian" decimal-separator="," 
grouping-separator="." />
<xsl:value-of select="format-number($price, '#.###,00', 'belgian')"/>

Thank you all!

Regards,
Gunter D'Hondt







Bertrand Delacretaz <bd...@apache.org> 
28-01-2005 10:50
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: decimal formatting






Le 28 janv. 05, à 10:20, Gunter D'Hondt a écrit :

> Bertrand,
>
> I've tried that but with no luck; it keeps using the en_US formatting
> instead of nl_BE (or fr_FR); does Cocoon overwrite this in some way?...

I don't think so, but what might happen is that your JVM doesn't have 
the nl_BE Locale installed.

Unless it's the container that you use to run Cocoon overwrites the 
settings?

The best way to find out is to write some code that gets information 
from the default Locale and prints it out, to see if your settings have 
been taken into account or not.

-Bertrand





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 28 janv. 05, à 10:20, Gunter D'Hondt a écrit :

> Bertrand,
>
> I've tried that but with no luck; it keeps using the en_US formatting
> instead of nl_BE (or fr_FR); does Cocoon overwrite this in some way?...

I don't think so, but what might happen is that your JVM doesn't have 
the nl_BE Locale installed.

Unless it's the container that you use to run Cocoon overwrites the 
settings?

The best way to find out is to write some code that gets information 
from the default Locale and prints it out, to see if your settings have 
been taken into account or not.

-Bertrand



Re: decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
Bertrand,

I've tried that but with no luck; it keeps using the en_US formatting 
instead of nl_BE (or fr_FR); does Cocoon overwrite this in some way?

I cannot believe that nobody in Europe haven't encountered that problem 
with Cocoon yet; in plain Java-code you can easily use 
java.textNumberFormat but how can you specify this in xsl or woody??? or 
just in general in a Cocoon webapp?

Gunter


 



Bertrand Delacretaz <bd...@apache.org> 
28-01-2005 09:28
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: decimal formatting






Le 27 janv. 05, à 14:24, Gunter D'Hondt a écrit :

> ...is there a way to set this for the whole Cocoon application? 
> something
> like setting the locale for the xslt-transformer?..

You can set the Locale globally at the JVM level, by setting the 
appropriate command-line options when starting the JVM.
Usually this is set by the user.language and user.country system 
properties.

Dunno if it would help in your particular case, but that's what I'd try 
first.

-Bertrand



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: decimal formatting

Posted by Conal Tuohy <co...@paradise.net.nz>.
> Gunter D'Hondt wrote:
> > I've also tried a plain java program and call it like this:
> > java -Duser.language=fr  -Duser.country=FR  -Duser.variant=FR Main
> >
> > java program:
> > public class Main {
> >
> >     public static void main(String[] args) {
> >
> >         double d=123.45;
> >         System.out.println("d="+d);
> >     }
> > }
> >
> > as you say this would output "d=123,45" but it always
> outputs "d=123.45"

> From: John L. Webber

> Have you tried using javax.swing.text.NumberFormatter?

I think John is right. You may have the Locale installed but not be using
it. System.out.println just ends up calling Double.toString(d) which is
really a canonical serialization of a double, not a locale-specific
rendering.
http://java.sun.com/j2se/1.3/docs/api/java/lang/Double.html#toString(double)

Con


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by "John L. Webber" <Jo...@jentro.com>.
Have you tried using javax.swing.text.NumberFormatter?

Gunter D'Hondt wrote:
> I've also tried a plain java program and call it like this:
> java -Duser.language=fr  -Duser.country=FR  -Duser.variant=FR Main
> 
> java program:
> public class Main {
> 
>     public static void main(String[] args) {
>  
>         double d=123.45;
>         System.out.println("d="+d);
>     }
> }
> 
> as you say this would output "d=123,45" but it always outputs "d=123.45"
> 
> Gunter
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 28 janv. 05, à 10:51, Bertrand Delacretaz a écrit :

> Le 28 janv. 05, à 10:33, Gunter D'Hondt a écrit :
>
>> ...as you say this would output "d=123,45" but it always outputs 
>> "d=123.45"..
>
> I don't know enough about Locale to tell if if "123,45" is indeed the 
> expected output, but this could indicate that the specified Locale is 
> not available in your JVM...

Take that back, I hadn't looked at your code properly. As the others, I 
don't think System.out cares for the Locale in any way, you have to use 
a MessageFormat or something for the Locale to be taken into account.

-Bertrand

Re: decimal formatting

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 28 janv. 05, à 10:33, Gunter D'Hondt a écrit :

> ...as you say this would output "d=123,45" but it always outputs 
> "d=123.45"..

I don't know enough about Locale to tell if if "123,45" is indeed the 
expected output, but this could indicate that the specified Locale is 
not available in your JVM.

-Bertrand


RE: Cocoon JDK 1.5 support

Posted by Ryan Agler <ry...@hotmail.com>.
Visit this link and apply the patch:

http://issues.apache.org/bugzilla/show_bug.cgi?id=33189 

> -----Original Message-----
> From: Justin Fagnani [mailto:justin3@fagnani.com] 
> Sent: Friday, January 28, 2005 4:15 PM
> To: users@cocoon.apache.org
> Subject: Re: Cocoon JDK 1.5 support
> 
> I'm not sure about Windows, but I got Cocoon compiling on 
> Linux with JDK 1.5. 
> I had to replace some of the Ant libs with newer versions and 
> recompile the ant tasks, but ti wasn't that big of a deal.
> 
> -Justin
> 
> On Friday 28 January 2005 01:45, Kristian Mandrup wrote:
> > Does anyone know when Cocoon will support JDK 1.5 on 
> windows, without 
> > "heavy tweaking" of build files. Haven't been able to make it work. 
> > Guess I could install JDK 1.4.2, compile Coccon 2.1.6, reconfigure 
> > JAVA_HOME to 1.5, and use cocoon with my JDK 1.5 "support code". I 
> > assume the ByteCode is compatible...? But still a bit 
> "messy" way to go about it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon JDK 1.5 support

Posted by Justin Fagnani <ju...@fagnani.com>.
I'm not sure about Windows, but I got Cocoon compiling on Linux with JDK 1.5. 
I had to replace some of the Ant libs with newer versions and recompile the 
ant tasks, but ti wasn't that big of a deal.

-Justin

On Friday 28 January 2005 01:45, Kristian Mandrup wrote:
> Does anyone know when Cocoon will support JDK 1.5 on windows, without
> "heavy tweaking" of build files. Haven't been able to make it work. Guess I
> could install JDK 1.4.2, compile Coccon 2.1.6, reconfigure JAVA_HOME to
> 1.5, and use cocoon with my JDK 1.5 "support code". I assume the ByteCode
> is compatible...? But still a bit "messy" way to go about it.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Cocoon JDK 1.5 support

Posted by Kristian Mandrup <kr...@mandrup.dk>.
Does anyone know when Cocoon will support JDK 1.5 on windows, without "heavy
tweaking" of build files. Haven't been able to make it work. Guess I could
install JDK 1.4.2, compile Coccon 2.1.6, reconfigure JAVA_HOME to 1.5, and
use cocoon with my JDK 1.5 "support code". I assume the ByteCode is
compatible...? But still a bit "messy" way to go about it.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.779 / Virus Database: 526 - Release Date: 19-10-2004
 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
I've also tried a plain java program and call it like this:
java -Duser.language=fr  -Duser.country=FR  -Duser.variant=FR Main

java program:
public class Main {

    public static void main(String[] args) {
 
        double d=123.45;
        System.out.println("d="+d);
    }
}

as you say this would output "d=123,45" but it always outputs "d=123.45"

Gunter






Bertrand Delacretaz <bd...@apache.org> 
28-01-2005 09:28
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: decimal formatting






Le 27 janv. 05, à 14:24, Gunter D'Hondt a écrit :

> ...is there a way to set this for the whole Cocoon application? 
> something
> like setting the locale for the xslt-transformer?..

You can set the Locale globally at the JVM level, by setting the 
appropriate command-line options when starting the JVM.
Usually this is set by the user.language and user.country system 
properties.

Dunno if it would help in your particular case, but that's what I'd try 
first.

-Bertrand



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 27 janv. 05, à 14:24, Gunter D'Hondt a écrit :

> ...is there a way to set this for the whole Cocoon application? 
> something
> like setting the locale for the xslt-transformer?..

You can set the Locale globally at the JVM level, by setting the 
appropriate command-line options when starting the JVM.
Usually this is set by the user.language and user.country system 
properties.

Dunno if it would help in your particular case, but that's what I'd try 
first.

-Bertrand

Re: decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
thanks John; but I'm currently only looking for the display formatting and 
not the input formatting (this will be for next week :-) )

so I'm assuming that you must be using something in order to get the 
display formatting correct?

Gunter


 



"John L. Webber" <Jo...@jentro.com> 
28-01-2005 09:03
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: decimal formatting






Hello Gunter,

I saw your mail yesterday, but wanted to see if anyone had a better 
solution than I.

AFAIK there's no easy way; we had a similar problem (can't control 
whether the users enter numbers European-style or North American-style). 
  We wrote our own FormValidatorAction (which we use to validate dates 
as well); in the validateValue(String name,
       Configuration constraints, Configuration conf, Map params,
       boolean isString, String type) method we added code to validate 
the "special" types we wanted, for example:

else if ("jdouble".equals(type)) {
           String strValue = value.toString();
           strValue = strValue.replace(',', '.');
           params.put(name, strValue);
           vaH = super.validateValue(name, constraints, conf, params, 
isString, "double");
}

Then we can use the type "jdouble" in our form-validation descriptor. Of 
course, more elegant solutions must be possible!

Hope this helps!

Regards,

John


Gunter D'Hondt wrote:
> Isn't anybody who knows how I can change the general decimal and 
thousand 
> seperator in a Cocoon application? How to switch them?
> 
> I've tried the LocaleAction but this only gives you the locale as a 
> parameter in your sitemap so that no use for decimal formatting
> 
> Any help is welcome!
> 
> Regards,
> Gunter D'Hondt
> 
> 
> 
> 
-- 
---------------------------------------------------------
  Jentro Technologies GmbH
  John L. Webber, Software Development
---------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by "John L. Webber" <Jo...@jentro.com>.
Hello Gunter,

I saw your mail yesterday, but wanted to see if anyone had a better 
solution than I.

AFAIK there's no easy way; we had a similar problem (can't control 
whether the users enter numbers European-style or North American-style). 
  We wrote our own FormValidatorAction (which we use to validate dates 
as well); in the validateValue(String name,
       Configuration constraints, Configuration conf, Map params,
       boolean isString, String type) method we added code to validate 
the "special" types we wanted, for example:

else if ("jdouble".equals(type)) {
           String strValue = value.toString();
           strValue = strValue.replace(',', '.');
           params.put(name, strValue);
           vaH = super.validateValue(name, constraints, conf, params, 
isString, "double");
}

Then we can use the type "jdouble" in our form-validation descriptor. Of 
course, more elegant solutions must be possible!

Hope this helps!

Regards,

John


Gunter D'Hondt wrote:
> Isn't anybody who knows how I can change the general decimal and thousand 
> seperator in a Cocoon application? How to switch them?
> 
> I've tried the LocaleAction but this only gives you the locale as a 
> parameter in your sitemap so that no use for decimal formatting
> 
> Any help is welcome!
> 
> Regards,
> Gunter D'Hondt
> 
> 
>  
> 
-- 
---------------------------------------------------------
  Jentro Technologies GmbH
  John L. Webber, Software Development
---------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
Isn't anybody who knows how I can change the general decimal and thousand 
seperator in a Cocoon application? How to switch them?

I've tried the LocaleAction but this only gives you the locale as a 
parameter in your sitemap so that no use for decimal formatting

Any help is welcome!

Regards,
Gunter D'Hondt


 



Gunter D'Hondt <gu...@sofico.be> 
27-01-2005 14:24
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
decimal formatting






Hi,

Currenlty I've got a Cocoon pipeline that generates HTML output by using a 

XSLT transformer where I'm using the following:
<xsl:value-of select="format-number(round(field), '##,##0.00')"/>

this all works fine and displays for example 12,345.99 but how can I setup 

this that it uses my country locale where the decimal separator is a comma 

and the thousand separator is a point? So the result would be 12.345,99

is there a way to set this for the whole Cocoon application? something 
like setting the locale for the xslt-transformer?

and what with the woody field convertors? for example i've got the 
following widget declaration:
  <wd:output id="price">
    <wd:label/>
    <wd:datatype base="decimal">
      <wd:convertor variant="number">
        <wd:patterns>
          <wd:pattern>#0.00</wd:pattern>
        </wd:patterns>
      </wd:convertor>
    </wd:datatype>
  </wd:output>

Any help is welcome!

Regards,
Gunter D'Hondt
Sofico NV Belgium

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


decimal formatting

Posted by Gunter D'Hondt <gu...@sofico.be>.
Hi,

Currenlty I've got a Cocoon pipeline that generates HTML output by using a 
XSLT transformer where I'm using the following:
<xsl:value-of select="format-number(round(field), '##,##0.00')"/>

this all works fine and displays for example 12,345.99 but how can I setup 
this that it uses my country locale where the decimal separator is a comma 
and the thousand separator is a point? So the result would be 12.345,99

is there a way to set this for the whole Cocoon application? something 
like setting the locale for the xslt-transformer?

and what with the woody field convertors? for example i've got the 
following widget declaration:
  <wd:output id="price">
    <wd:label/>
    <wd:datatype base="decimal">
      <wd:convertor variant="number">
        <wd:patterns>
          <wd:pattern>#0.00</wd:pattern>
        </wd:patterns>
      </wd:convertor>
    </wd:datatype>
  </wd:output>

Any help is welcome!

Regards,
Gunter D'Hondt
Sofico NV Belgium

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Include pipeline content in another servlet

Posted by Olivier Billard <ol...@laposte.net>.
Thanks for your answer Leszek,

Unfortunately, the Cocoon pipes are working with informations stored in session or request attributes...
How do you handle these ? It would be too much work to change this to use only request params...

--
Olivier

Leszek Gawron wrote:
> Olivier Billard wrote:
> 
>> Hi cocooners,
>>
>> For some design constrainst, I would like from another servlet, to 
>> tell Cocoon to output files.
>> A wrapper has been made around the CocoonServlet to redirect servlet 
>> outputstream to a file. That's the existing part.
>> Then in a servlet I would like to tell Cocoon to output a file here is 
>> a snippet :
>>
>> request.getRequestDispatcher(cocoonPipeline).include(request, response);
>>
>> The problem is that Cocoon bases request processing over the 
>> request.getServletPath() to get the URI, and this don't change from 
>> the request that originally called the calling servlet...
>>
>> So is there a better and working method to call file outputting to the 
>> Cocoon servlet from another servlet ?
>>
>> Thanks,
>>
>> -- 
>> Olivier Billard
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
> use of CocoonBean maybe ?
> http://cocoon.apache.org/2.1/userdocs/offline/bean.html
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Include pipeline content in another servlet

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Olivier Billard wrote:
> Hi cocooners,
> 
> For some design constrainst, I would like from another servlet, to tell 
> Cocoon to output files.
> A wrapper has been made around the CocoonServlet to redirect servlet 
> outputstream to a file. That's the existing part.
> Then in a servlet I would like to tell Cocoon to output a file here is a 
> snippet :
> 
> request.getRequestDispatcher(cocoonPipeline).include(request, response);
> 
> The problem is that Cocoon bases request processing over the 
> request.getServletPath() to get the URI, and this don't change from the 
> request that originally called the calling servlet...
> 
> So is there a better and working method to call file outputting to the 
> Cocoon servlet from another servlet ?
> 
> Thanks,
> 
> -- 
> Olivier Billard
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
use of CocoonBean maybe ?
http://cocoon.apache.org/2.1/userdocs/offline/bean.html

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
Project Manager                                    MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org