T5: how to obtain the current session's locale in a Translator?

2007-07-13 Thread Martin Dietze
Hi,

 I am currently working on Ted's DatePicker component. It uses
a Translator for parsing the entered String and convert it into
a Date object. The Translator is registered like this:

| public static void contributeTranslatorSource(MappedConfiguration configuration) {
| configuration.add("jsCalendarDateTranslator", new DateTranslator());
| }

My problem is the date format is pretty locale-dependent. In
Germany we would use something like dd.mm.yy or dd.mm.
while in the English-speaking world we could have stuff like 
/mm/dd.

Ideally I'd like the Translator to obtain the currently set
locale (set using the ThreadLocale service in my main layout
module which has a Language-dropdown) and use the date format
which is most appropriate for it.

However I found that any attempt to @Inject Locale,
ThreadLocale or PersistentLocale always gave me null values.
If I interpret the documentation well this should be expected
anyway since a Translator is not a component (?), but what else
can I do?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
In C you need #define to get real constants, like "#define FOO (rand())"

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 / DatePicker: Error obtaining injected value for field

2007-07-12 Thread Martin Dietze
Again answering myself...

On Thu, July 12, 2007, Martin Dietze wrote:

> Exception constructing service
> 'ClasspathAssetAliasManager': Error invoking constructor
> org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl(Request,
> Map) (at ClasspathAssetAliasManagerImpl.java:50) (for service
> 'ClasspathAssetAliasManager'): Error invoking service contribution method
> net.keso.ted.jscalendar.JsCalendarModule.contributeClasspathAssetAliasManager(MappedConfiguration,
> String): Exception constructing service 'ClasspathAssetAliasManager':
> Construction of service 'ClasspathAssetAliasManager' has failed due
> to recursion: the service depends on itself in some way. Please check
> org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl(Request,
> Map) (at ClasspathAssetAliasManagerImpl.java:50) for references to another
> service that is itself dependent on service 'ClasspathAssetAliasManager'.

Having browsed the T5 sources a bit I found this solution:

[file JsCalendarModule.java]

|public static void contributeClasspathAssetAliasManager(
|MappedConfiguration configuration,
|@Symbol("net.keso.ted.jscalendarscript.path")
|String jsCalendarScriptPath)
|{
|configuration.add("jscalendar/", jsCalendarScriptPath + "/");
|}


Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Katz' Law: Man and nations will act rationally when all other 
   possibilities have been exhausted. 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 / DatePicker: Error obtaining injected value for field

2007-07-12 Thread Martin Dietze
Replying to myself...

On Thu, July 12, 2007, Martin Dietze wrote:

> I modified these like this:
> 
> | @Inject
> | @Value("${net.keso.ted.jscalendarscript}/button-image.png")
> | private Asset defaultButtonImage;

As I now understand it, the code above should read:

| @Inject
| @Path("${net.keso.ted.jscalendarscript}/button-image.png")
| private Asset defaultButtonImage;

This change made the original error disappear. However I am now
struggleing with this problem here:

Exception constructing service 'ClasspathAssetAliasManager': Error invoking 
constructor 
org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl(Request, 
Map) (at ClasspathAssetAliasManagerImpl.java:50) (for service 
'ClasspathAssetAliasManager'): Error invoking service contribution method 
net.keso.ted.jscalendar.JsCalendarModule.contributeClasspathAssetAliasManager(MappedConfiguration,
 String): Exception constructing service 'ClasspathAssetAliasManager': 
Construction of service 'ClasspathAssetAliasManager' has failed due to 
recursion: the service depends on itself in some way. Please check 
org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl(Request, 
Map) (at ClasspathAssetAliasManagerImpl.java:50) for references to another 
service that is itself dependent on service 'ClasspathAssetAliasManager'.  

Still happy to get any hint...

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
machen.  -- Lutz Donnerhacke in dasr

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5 / DatePicker: Error obtaining injected value for field

2007-07-12 Thread Martin Dietze
Hi,

 I am trying to get the DatePicker class from the
tapestry5-jscalendar package [1] to work with the latest 5.0.5
snapshot. The code did not compile initially since there were
@Inject annotations like this one:

| @Inject("${net.keso.ted.jscalendarscript}/button-image.png")
| private Asset defaultButtonImage;

I modified these like this:

| @Inject
| @Value("${net.keso.ted.jscalendarscript}/button-image.png")
| private Asset defaultButtonImage;

Now the code compiled.

However when trying to use the DatePicker in a page I now
get this error:

#  java.lang.ClassNotFoundException
caught an exception while obtaining a class file for 
net.keso.ted.jscalendar.components.DatePicker

exception
org.apache.tapestry.internal.services.TransformationException: Error 
obtaining injected value for field 
net.keso.ted.jscalendar.components.DatePicker.defaultButtonImage: Could not 
find a coercion
from type java.lang.String to type org.apache.tapestry.Asset. Available 
coercions: Double --> Float, Float --> Double, Long --> Boolean, Long --> Byte, 
Long --> Double, Long --> Integer, Long -->
Short, Number --> Long, Object --> String, Object --> java.util.List, Object[] 
--> java.util.List, String --> Boolean, String --> Double, String --> Long, 
String --> java.math.BigDecimal, String -->
java.math.BigInteger, String --> org.apache.tapestry.SelectModel, String --> 
org.apache.tapestry.corelib.data.GridPagerPosition, java.math.BigDecimal --> 
Double, java.util.Collection --> Boolean,
java.util.List --> java.util.Set, java.util.List --> 
org.apache.tapestry.SelectModel, java.util.List --> 
org.apache.tapestry.grid.GridDataSource, java.util.Map --> 
org.apache.tapestry.SelectModel,
java.util.Set --> java.util.List, null --> Boolean, null --> String, null --> 
java.util.List, null --> org.apache.tapestry.grid.GridDataSource. 

Are there any API changes from 5.0.3 to 5.0.5 that could have
caused this problem, or does anyone know what to do here?

Cheers,

Martin

[1] http://tapestry5-jscalendar.googlecode.com/svn/trunk/

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Aber zur rechten Zeit noch ergriff mich beim Fuss der Kapitaen. Er zog mich 
vom Schiffsrand und rief, aergerlich lachend: Doktor, sind Sie des Teufels?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Set component parameters from page class

2007-07-02 Thread Martin Dietze
On Mon, July 02, 2007, Francois Armand wrote:

>@Component(parameters="disabled=prop:isdisabled")
>private TextField textField;
>   
>public boolean getIsdisabled() {
>return disabled;
>}
>@SetupRender
>void setup() {
>   if(should de disabled) {
>disabled = true;
>   } else {
>  disabled = false;
>   }
>}

This helped, thank you! 

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Steht ein Bratscher vor 'ner Kneipe.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Set component parameters from page class

2007-07-02 Thread Martin Dietze
On Mon, July 02, 2007, Francois Armand wrote:

> I'm not sure I have correctly understood your concern, so excuse me if I 
> answer to something else ;)
> When you have a component with parameter, you have two way to specify it 
> the actual parameter value :
> - in the template, with "paramname=bindingtype:value" ;
> - in the java code, thanks to "@Component(parameters =..." tag.

Yes, this is how I found it in the documentation. However I'd
like to be able to do something like:

| @Component(id="myInput")
| private TextField _myInput;

[...]

| _myInput.setDisabled(true);

Why this? I try to create encapsulate frequently-needed units
from my templates as components. E.g. you may want to use the
same HTML template (plus page class) for creating a user as
well as for modifying a user. Depending on the application
there may be some differences between the two applications of
the component, i.e. when modifying a user some properties are
read-only. 

Of course I can accomplish this with the code you posted, but 
this requires me to add the appropriate "parameters" annotation,
"paramname=bindingtype:value" plus a getter and setter for each
input I want to handle. Since the code already is pretty lengthy
anyway this will make it even messier.  

Doing this by a single setter per input at beginRender() would
be much simpler and readable.

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Was ist der Unterschied zwischen einer Bratsche und einer Waschmaschine?
Die Waschmaschine vibriert, kommt erst am Ende ins Schleudern, und was 
rauskommt, ist sauber.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Set component parameters from page class

2007-07-02 Thread Martin Dietze
On Mon, July 02, 2007, Massimo Lusetti wrote:

> > I'd like to set some component paramameters ("disabled" for
> >inputs) from within my page classes. As far as I've seen so far
> >the usual way to do this would be to put a "name=${prop:value}"
> >attribute into my template. Can this also be done by using a
> >simple setter in my Java code? This would improv the templates'
> >readability a lot!
> 
> Search through the archives for and old thread from the early days of
> T5, maybe you will find some hints.

Have you got any hint regarding title / keywords? I did a
search before I posted, but I did not find anyting appropriate,
maybe I just did not look for the right thing...

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Albert Camus wrote that the only serious question is whether to kill yourself
or not.  Tom Robbins wrote that the only serious question is whether time has
a beginning and an end.  Camus clearly got up on the wrong side of bed, and
Robbins must have forgotten to set the alarm.  -- Tom Robbins

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Set component parameters from page class

2007-07-02 Thread Martin Dietze
Hi,

 I'd like to set some component paramameters ("disabled" for
inputs) from within my page classes. As far as I've seen so far
the usual way to do this would be to put a "name=${prop:value}"
attribute into my template. Can this also be done by using a
simple setter in my Java code? This would improv the templates'
readability a lot!

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
machen.  -- Lutz Donnerhacke in dasr

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: Conditional JavaScript code

2007-06-27 Thread Martin Dietze
Hi,

 I would like to add inline JavaScript code to a form depending
on conditions set within the page class. I thus wrote code like
this:

| 
| function myFunc() {
| 
|   for (var i = 0; i < someConstant; i++) {
| doSomethin();
|   }
| 
| }
| 

This code causes problems since obviously Tapestry expects
well-formed HTML code here (note the '<' character). I also run
into problems if I put the inline JavaScript into HTML
comments, the code gets completely ignored then.

Since after each submit of the form the condition in the 
changes I don't really see any alternative to this construct,
or is there any fix/better way to do this?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Yoda of Borg I am. Assimilated you will be.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: replacing Messages with my @Service

2007-06-25 Thread Martin Dietze
Hi,

 we recently derived our own Messages class from AbstractMessages
to replace T5's i18n mechanisms by our own. We created a (spring)
service "i18nMessages" for it and used code like this in page
classes:

|  @Inject
|  @Service("i18nMessages")
|  private Messages _messages;

It turned out that T5 never used the i18nMessages service.
Actually you can write whatever you want as name for the
service, it seems to get completely ignored, T5 always uses
org.apache.tapestry.ioc.Messages as type for the object.

This problem does of course not occur if I let my Messages
class additionally implement my own interface "MyMessages"
which may even be identical to T5's Messages interface and
define my _messages field of type MyMessages.

However I wonder why it does not work with T5's Messages? Am I
misusing the framework or is this a bug?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
- Oh, Norris. You made a mistake. Mrs. Rutledge didn't want to see me.
- I'm sorry, Sir. I make many mistakes.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Grid: Failure writing parameter rowsPerPage [...] is read-only.

2007-06-21 Thread Martin Dietze
Hi,

 consider the following code:

[ in the template ]

| 

[ in the page class ]

| @Component(id = "EntryGrid")
| private Grid _grid;

[...]

| private int _rowsPerPage;

[...]

| public void onSuccessFromGridForm() {
|  _rowsPerPage = getNewRowsPerPage();
| _grid.setRowsPerPage(_rowsPerPage);
| }

Whenever I call `_grid.setRowsPerPage()' I get the following
exception:

| org.apache.tapestry.ioc.internal.util.TapestryException
| Failure writing parameter rowsPerPage of component MyForm:entrygrid: Binding
| [EMAIL PROTECTED] is read-only.

| Stack trace

| * 
org.apache.tapestry.internal.bindings.AbstractBinding.set(AbstractBinding.java:46)
| * 
org.apache.tapestry.internal.structure.InternalComponentResourcesImpl.writeParameter(InternalComponentResourcesImpl.java:235)
| * 
org.apache.tapestry.corelib.components.Grid._$update_parameter_rowsPerPage(Grid.java)
| * org.apache.tapestry.corelib.components.Grid.setRowsPerPage(Grid.java:268)

What am I doing wrong?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Interested in sophisticated fun? You, hubby, girl friends. The more the 
merrier. Get in touch with Kirby, through WASTE only, Box 7391, L.A.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: change a grid's rowsPerPage property dynamically?

2007-06-20 Thread Martin Dietze
On Wed, June 20, 2007, Martin Dietze wrote:

> I tried this, too, but calling the setRowsPerPage() method from
> within my page class had no effect either.

Folowing up my own posting - the problem is still unsolved, has
anyone found a solution to this?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
In an organization, each person rises to the level of his own incompetency.
   -- The Peter Principle 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: change a grid's rowsPerPage property dynamically?

2007-06-20 Thread Martin Dietze
On Wed, June 20, 2007, Martin Grotzke wrote:

> Would it be possible to have the grid component in your page class
> so that you can update the rowsPerPage property directly?

I tried this, too, but calling the setRowsPerPage() method from
within my page class had no effect either.

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
What would happen in a battle between an Enterprise security team, who always 
get killed soon after appearing, and a squad of Imperial Stormtroopers, who 
can't hit the broad side of a planet?  --Tom Galloway 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: change a grid's rowsPerPage property dynamically?

2007-06-19 Thread Martin Dietze
Hi,

 I am using a Grid component for displaying a larger set of
data. On my page I have form which I use to allow the user to
set the perferred page size. When the user selects a new
setting the form submits and changes the page class'es
_rowsPerPage property which is used by the grid in the template
to determine its number of rows like this:

|  

My _rowsPerPage property get set to the right value after
submit, however the grid seems to ignore any changes from the
default it has been created with. Could it be the rowsPerPage
setting is cached somehow? How can I get the component to honor
new settings?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Hlade's Law: If you have a difficult task, give it to a lazy person;
   they will find an easier way to do it. 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: inherited @Parameter's in component classes

2007-06-11 Thread Martin Dietze
Hi,

On Fri, June 08, 2007, Martin Dietze wrote:

>  I tried to inherit some compoment classes from an abstract
> component base class which contains some propeties the above
> share. In the template I would then use these components like
> this:
> 
>   
> 
> In the base class I have:
> 
>   @Parameter
>   private String _myCommonParam;
> 
>   public String getMyCommonParam() { return _myCommonParam; }
>   public void setMyCommonParam(myCommonParam) { _myCommonParam = 
> myCommonParam; } 
> 
> However it seems like the member variable in the base class 
> never gets touched, the getters and setters not used.

 I forgot to mention that putting the above code directly
into my component class works flawlessly, it only seems like
the @Parameter does not survive inheritance...

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Es gibt Themen genug in Deinem eigenen Leben, und wenn sie einmal ausgehn,
gibt es Themenlaeden.  -- Die Sterne

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: inherited @Paramet's in components

2007-06-08 Thread Martin Dietze
Hi,

 I tried to inherit some compoment classes from an abstract
component base class which contains some propeties the above
share. In the template I would then use these components like
this:

  

In the base class I have:

  @Parameter
  private String _myCommonParam;

  public String getMyCommonParam() { return _myCommonParam; }
  public void setMyCommonParam(myCommonParam) { _myCommonParam = myCommonParam; 
} 

However it seems like the member variable in the base class 
never gets touched, the getters and setters not used.

Can such parameters not be inherited at all?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
- Oh, Norris. You made a mistake. Mrs. Rutledge didn't want to see me.
- I'm sorry, Sir. I make many mistakes.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: property lifecycle again

2007-06-07 Thread Martin Dietze
On Thu, June 07, 2007, Davor Hrg wrote:

> It's a guess, but I think that you just need to persist the property.
> @Persist("flash")

That's what I thought, but it does not work. It seems to have
to do with the way T5 initializes its member variables (my
guess)... 

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Hlade's Law: If you have a difficult task, give it to a lazy person;
   they will find an easier way to do it. 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: property lifecycle again

2007-06-07 Thread Martin Dietze
Hi,

 I want to load a page which displays a particular entry from a
database. To accomplish this I create an action link in the
parent page which causes the parent page's object to call a
method of my display-an-entry page object passing the DB-bean
as a parameter. Within that method I assign this object to a
member variable which is supposed to allow me to read and
display its data on the page.

Unfortunaetly the value of that member variable gets reset
before the page can be rendered. It seems like member vars like
this one are supposed to be initialized at a later stage within
the page's lifecycle.

Does this mean that the way I am doing it (by passing on the
object as an argument) is fundamentally wrong, or which would
be an elegant way to do this?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
My name is spelled Luxury Yacht but it's pronounced Throatwabbler Mangrove.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: How to display an enum?

2007-06-06 Thread Martin Dietze
Hi,

 for enum-based select inputs I can use value encoders to get
my enum's tags displayed correctly. Now I have a template in
which I need to display an enum variable. How can I use a
mechanism similar to the one for select inputs?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Last yeer I kudn't spel Engineer.  Now I are won.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: How to generate page links from Java code?

2007-06-01 Thread Martin Dietze
Hi,

 I'm trying to create a component for a navigation element
which contains page links for all of my pages but renders the
currently loaded page differently (i.e. not a href, different
font etc.).

It seems to me like the best way to do this is have my
component's java code write the lines containing the titles and
the underlying links.

Unfortunately I have not been able to find any example how to
do this, in all examples I found the links were created in the
html template rather than the java code.

Can anyone here help me out?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
"We waste time looking for the perfect lover, instead of creating the
perfect love."  -- Tom Robbins, _Still Life With Woodpecker_

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: when is @Persist necessary and when not...

2007-06-01 Thread Martin Dietze
On Thu, May 31, 2007, Ben Sommerville wrote:

> For a form I'd say the best place to create those compound objects
> is in the onPrepare method.  This will be invoked before any processing/
> rendering occurs.  (see the Form component subsection of 
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/validation.html)
> 
> Another option is the pageAttached method (invoked when page
> is attached to the request) which is documented at
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html

Hmm, having tried both these options this leads to the objects
being replaced by defaults before the resultpage after a submit
is created, thus my submit results (the variables are annotated
with "@Persist") get lost. Or am I misunderstanding something
completely?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Wie verhindert man, dass einem die Geige gestohlen wird?
Man legt sie in einen Bratschenkasten...

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: select using a wrapped enum

2007-05-31 Thread Martin Dietze
On Thu, May 31, 2007, Howard Lewis Ship wrote:

> Have you considered using OptionGroups as the labels?

To me it seemed that if I have to create a number of selects
with similar structure, just plugging in the appropriate enum
might actually be an elegant solution. 

Do you seen anything wrong with the way I implemented this?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
- Are you attempting to tell me my duty, sir?
- No. Just having fun trying to guess what they are.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using my own localization backend

2007-05-31 Thread Martin Dietze
On Thu, May 31, 2007, SergeEby wrote:

> You can provide your own implementation by contributing to aliasOverrides:
> 
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/alias.html

Thank you for your reply. I took a look at that page, but I do
not quite understand it. It seems like I lack some a-priori
knowledge on some of T5's concepts.

Could you give me a quick example and / or some hint on how I
could facilitate this mechanism for using my own localization
backend?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
In an organization, each person rises to the level of his own incompetency.
   -- The Peter Principle 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: Using my own localization backend

2007-05-31 Thread Martin Dietze
Hi,

 I need to use a particular localization backend for my
project. As I understand, T5 provides its own code for
retrieving messages based on the .properties files, and if
I understand Howard's posting from Mar 4 right, simply
plugging in my own ComponentMessageSource implementation
is not yet supported.

Would it make any sense trying to circumvent T5's message
facilities and implement my own which I could access by a
different prefix, i.e. "msg:", or is this complete nonsense?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
manche meinen, lechts und rinks kann man nicht velwechsern.
werch ein illtum!  -- elnst jandr

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: select using a wrapped enum

2007-05-31 Thread Martin Dietze
Hi,

 I created a selectmodel based on a enum wrapped by a generic
wrapper and using a generic value encoder.

By this I intend to simplify creating select inputs consisting of
something like "please select" and "" followed by the enum's
entries which are the only valid inputs for the select.

The code seems to work well, I the select options are created
properly and show up in the form, also selected values are 
delivered after submit. However when rendering the result page
the previously submitted option is not selected.

I wonder whether my code is not OK or do I have to insert some
code on my own to get the last choice selected in the result
page?

Cheers,

Martin

<--- snip ->

Here is my code:

The selectmodel:

|  public final class SalutationSelectModel extends AbstractSelectModel {
|  private final Messages _msgs;
|
|  public SalutationSelectModel(final Messages msgs) {
|_msgs = msgs;
|  }
|
|  public List getOptionGroups() {
|return null;
|  }
|  public List getOptions() {
|final List result = new ArrayList();
|
|// Add "please select..." entry and disabled "--"...
|result.add(new OptionModelImpl(_msgs.get("select_pleaseSelect"),
|  false, null, new String[0]));
|result.add(new OptionModelImpl(_msgs.get( "select_separator"),
|  true, new CommonSelectView(null), new String[0]));
|
|for(Salutation salut : Salutation.values()) {
|  result.add(new OptionModelImpl(_msgs.get("salutation_" + salut.name()),
|  false, new CommonSelectView(salut), new String[0]));
|}
|
|return result;
|  }
|}

The enum:

| public enum Salutation {
|   MR,
|   MRS;
| }

The generic enum wrapper:

| public class CommonSelectView {
|   private final M _model;
|   public CommonSelectView(M model) {
| _model = model;
|   }
|   public M getModel() {
| return _model;
|   }
| }

The generic value encoder lets me differenciate between
invalid inputs (like "please select") and disabled ones so
that I do not get more than one selected="selected" when
the page is displayed for the first time:

| ValueEncoder> implements ValueEncoder> {
| 
|   private Class _cls;
|   public CommonValueEncoder(Class cls) {
| _cls = cls;
|   }
| 
|   public String toClient(CommonSelectView value) {
| if (value == null) {
|   return "null";
| } else if (value.getModel() == null) {
| return "disabled";
| }
| return value.getModel().name();
|   }
| 
|   public CommonSelectView toValue(String clientValue) {
| if ("null".equals( clientValue) || "disabled".equals(clientValue)) {
|   return null;
| }
| M m = Enum.valueOf(_cls, clientValue);
| return new CommonSelectView(m);
|   }
| }

All this is used in this page class:

| public class CreatePartner {
|   @Inject
|   private Messages _messages;
|   @Component
|   private Form _form;
|   @Persist
|   private CommonSelectView _contactSalutation;
| 
|   private static ValueEncoder>
| _salutationValueEncoder = new 
CommonValueEncoder(Salutation.class);
|   private SelectModel _salutationModel;
| 
|   public CreatePartner() {
| _salutationModel = new SalutationSelectModel( _messages );
|   }
| 
|   @OnEvent(value="submit")
|   public void submit() {
| _form.recordError("Submit received: "
|   + (_contactSalutation != null? _contactSalutation.getModel() : "null"));
|   }
| 
|   public SelectModel getSalutationModel() {
| return _salutationModel;
|   }
| 
|   public ValueEncoder> 
getSalutationValueEncoder() {
| return _salutationValueEncoder;
|   }
| 
| 
|   public CommonSelectView getContactSalutation() {
| return _contactSalutation;
|   }
| 
|   public void setContactSalutation(CommonSelectView 
contactSalutation) {
| _contactSalutation = contactSalutation;
|   }
| 
| }

Finally, in the form I have this entry for the select:

| 
|   bitte wählen...
|   ---
|   Herr
|   Frau
| 

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
* Free Speech Online!!! Support the Blue Ribbon Campaign! *

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: when is @Persist necessary and when not...

2007-05-31 Thread Martin Dietze
On Wed, May 30, 2007, Howard Lewis Ship wrote:

> >On 5/30/07, Martin Dietze < [EMAIL PROTECTED]> wrote:

[...]

> >> > >For all these I have getters and setters defined.
> >> > >
> >> > >In my page class I have a constructor like this:
> >> > >
> >> > >| public CreatePartner() {
> >> > >|   _contact = new Person();
> >> ^^^ `person' of course!
> >> > >| }

[...]

> Just noticed your constructor. Don't do that.
> 
> The Person object that you create will become the default value for this
> property, rather than null.  This is documented.

This is strange. If the _person member variable gets reset to
the default at the end of each request I would expect not to
see the values from it on my page after submit in the render
request.

What I want to achieve is very much the same scenario found in
the documentation section "Form Input and Validation", only I
have several compound objects like `Person'. Since the form
accesses members of these objects they need to be created in
the page class. Since the constructor is obviously not the
right place for this, which one would you suggest?

Cheers,

Martin

-- 
--- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Was ist ein Cluster?
Wenn vier Bratscher unisono spielen.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: when is @Persist necessary and when not...

2007-05-30 Thread Martin Dietze
On Wed, May 30, 2007, Howard Lewis Ship wrote:

> >I have a page class which keeps form data like this:
> >
> >| // class MyForm
> >| private Person _person;
> >| private String _homepage;
> >
> >The class Person consists of several fields:
> >
> >| // class Person
> >| private String _firstName
> >| private String _lastName
> >
> >For all these I have getters and setters defined.
> >
> >In my page class I have a constructor like this:
> >
> >| public CreatePartner() {
> >|   _contact = new Person();
^^^ `person' of course!
> >| }

[...]

> Tapestry uses a redirect-after-post for actions, including form submits.
> Thus if the data is stored persistently, usually in the HttpSession, it is
> gone on the second request, the one that actually renders a response.

> If you used the debugger, you'd see that your _person field would also be
> null in the second request, the render request. You just aren't using it.

Interestingly this does not seem to be the case in my
application. Debugging the above class I find that when the
page is rendered after submit the `Person' object still
contains the submitted values.

Additionally `_$person_default' object (as I guess created by 
T5) contains the values of the populated person object.

For the `_homeapage' object which is an ordinary String, the
values are lost unless I put a [EMAIL PROTECTED]("flash")' above it
which should be expected according to your post. Now I wonder
why does the Person object seem to behave differently?

Cheers,

Martin

-- 
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
The only "intuitive" interface is the nipple. After that, it's all
learned.  -- Bruce Ediger 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: when is @Persist necessary and when not...

2007-05-30 Thread Martin Dietze
Hi,

 I have a page class which keeps form data like this:

| // class MyForm
| private Person _person;
| private String _homepage;

The class Person consists of several fields:

| // class Person
| private String _firstName
| private String _lastName

For all these I have getters and setters defined.

In my page class I have a constructor like this:

| public CreatePartner() {
|   _contact = new Person();
| }

When I submit data in my form all the above gets written
to the database as expected. However the textinput referring
to the _homepage member variable is always empty.

Now if I annotate the _homepage member variable using
@Persist("flash"), I get the data displayed as expected.
This seems to indicate that simple objects are somehow
treated differently from the way compound objects are
treated?

Strictly speaking I would not expect to need any persistence
annotation here at all since I am only handling submitted
data, or do I misunderstand anything here?

Cheers,

Martin

P.S.: These is the relevant entries in my form:

| 

[...]

| 

[...]

| 


Martin

-- 
------ Martin Dietze --- / -- freiheit.com --
-- [EMAIL PROTECTED] -- / -- [EMAIL PROTECTED] -
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Last yeer I kudn't spel Engineer.  Now I are won.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: No tag rendered when using enum

2007-05-29 Thread Martin Dietze
On Tue, May 29, 2007, Martin Dietze wrote:

> On Tue, May 29, 2007, Howard Lewis Ship wrote:
> 
> > Just hasn't been fleshed out yet; there needs to be a negotiation between
> > the MarkupWriterFactory service and the page that does the rendering to
> > determine the correct MarkupWriter configuration for the result.
> 
> sorry, -v, please :)

I guess that was a bit too short - I merely wanted to ask for
more details; do I get right this has not been implemented yet
but is in the process of being implemented?

Cheers,

Martin

-- 
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
My family says I'm a psychopath, but the voices in my head disagree

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: No tag rendered when using enum

2007-05-29 Thread Martin Dietze
On Tue, May 29, 2007, Howard Lewis Ship wrote:

> Just hasn't been fleshed out yet; there needs to be a negotiation between
> the MarkupWriterFactory service and the page that does the rendering to
> determine the correct MarkupWriter configuration for the result.

sorry, -v, please :)

Cheers,

Martin

-- 
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
while (!asleep)
  ++sheep;

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: more than one select options set to selected="selected"

2007-05-29 Thread Martin Dietze
Hi,

 I use a custom select model based on an AbstractSelectModel
and using a custom ValueEncoder. When running the code I get
this here generated (newlines added by me *g*):

| 
| bitte wählen...<
|  option disabled="disabled" selected="selected" value="null">---<
|  option value="MR">Herr<
|  option value="MRS">Frau
| <
|  img alt="[Error]" class="t-error-icon t-invisible" id="salution:icon"
|  src="/my-application-foo/assets/tapestry/field-error-marker.png">

As you see the first two options have the attribute "selected"
which is of course not what I want.

Now I wonder is this a bug or a feature (i.e. my bug *g*)?

Cheers,

Martin

<-- snip / my code >

The relevant snippet from the template looks like this:

| 
| bitte wählen...
| ---
| Herr
| Frau
| 

This is the selectmodel:

| public final class SalutationSelectModel extends AbstractSelectModel {
| 
|   private final Messages _msgs;
| 
|   public SalutationSelectModel( final Messages msgs ) {
| _msgs = msgs;
|   }
| 
|   public List getOptionGroups() {
| return null;
|   }
| 
|   public List getOptions() {
| final List result = new ArrayList();
| result.add( new OptionModelImpl( _msgs.get( "select_pleaseSelect" ),
| false, null, new String[0] ) );
| result.add( new OptionModelImpl( _msgs.get( "select_separator" ),
| true, null, new String[0] ) );
| for( Salutation salut : Salutation.values() ) {
|   result.add( new OptionModelImpl( _msgs.get( "salutation_" + 
salut.name() ),
|   false, salut, new String[0] ) );
| }
| 
| return result;
|   }
| 
| }

And (if at all relevant) the valueencoder:

| public class SalutationValueEncoder implements ValueEncoder {
|
|   public String toClient( Salutation value ) {
| if ( value == null )
|   return "null";
| return value.name();
|   }
| 
|   public Salutation toValue( String clientValue ) {
| if ( "null".equals( clientValue ) )
|   return null;
| return Salutation.valueOf( clientValue );
|   }
| 
| }


-- 
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
Was ist ein Cluster?
Wenn vier Bratscher unisono spielen.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: No tag rendered when using enum

2007-05-29 Thread Martin Dietze
Hi,

> Howard Lewis Ship wrote on Sat, 24 Mar 2007 11:42:22 -0800

> This is correct behavior for rendering HTML (as opposed to XHTML).
> Unlike T4, T5 knows the difference.  HTML is a SGML language where
> open tags are not necessarly balanced with close tags.

> What's coming is the ability for Tapestry to render XML/XHTML
> correctly and choose the correct strategy (HTML vs. XML/XHTML)
> automatically.

 does this imply that T5 will be able to do this one day or is
there any way to enforce XHTML-compliant output with T5 as it
is now?

Cheers,

Martin

-- 
- / http://herbert.the-little-red-haired-girl.org / -
=+= 
WE ARE THE BORG - RESISTANCE IS VOLTAGE DIVIDED BY CURRENT!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]