Re: T5 Localized Select

2008-02-10 Thread Davor Hrg
You have to be aware:

@Inject is intended for pages, components...
and if your option model is a service
then you have to inject services by declaring it in the constructor.

Davor Hrg

On 2/10/08, Olivier Jacquet [EMAIL PROTECTED] wrote:
 Hello,


 I'm trying to build a select component which allows you to select a
 country. The labels would be the country names and the values the ISO
 codes for the country. The catch is that I want the country names
 displayed in the current locale.

 Now, when you @Inject the messages in the OptionModel it is null when
 you try to access it in getLabel() and I was wondering if that is
 intended? Now I have to pass the catalog from my wrapper component
 (SelectCountry) with its own catalog to my SelectModel which passes it
 down to the OptionModel. That doesn't feel right.

 Wouldn't it be nice to be able to access the Messages from within the
 OptionModel and get access to the resources from the wrapper component?


 Best regards,
 Olivier


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



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



T5: BeanEditForm not setting values for custom parameters

2008-02-10 Thread Olivier Jacquet

Say that I have

a bean Company.java:
class Company {
  private String name;
  private String city;
}

a page CreateCompany.java:
class CreateCompany {
  private Company company;
  void onValidate() {
System.out.println(name:  + company.getName() +  city:  + 
company.getCity());

  }

a template CreateCompany.tpl
html xmlns:t=
  t:beaneditform t:id=company
t:parameter name=city
  t:label for=city/
  t:textfield t:value=company.city t:id=city/
/t:parameter
  /t:beaneditform
/html


I fill in values for both fields and I submit. The println will print 
the value for the name but the city will be NULL. How come?



Best regards,
Olivier

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



Re: T5: BeanEditForm not setting values for custom parameters

2008-02-10 Thread Olivier Jacquet
I'm sorry to spam. Apparently there is separate validate loop voor the 
custom parameters.



Have a nice day,
Olivier



Olivier Jacquet wrote:

Say that I have

a bean Company.java:
class Company {
  private String name;
  private String city;
}

a page CreateCompany.java:
class CreateCompany {
  private Company company;
  void onValidate() {
System.out.println(name:  + company.getName() +  city:  + 
company.getCity());

  }

a template CreateCompany.tpl
html xmlns:t=
  t:beaneditform t:id=company
t:parameter name=city
  t:label for=city/
  t:textfield t:value=company.city t:id=city/
/t:parameter
  /t:beaneditform
/html


I fill in values for both fields and I submit. The println will print 
the value for the name but the city will be NULL. How come?



Best regards,
Olivier

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




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



Re: T5 Localized Select

2008-02-10 Thread Harald Geritzer

Now, when you @Inject the messages in the OptionModel it is null when
you try to access it in getLabel() and I was wondering if that is
intended? Now I have to pass the catalog from my wrapper component
(SelectCountry) with its own catalog to my SelectModel which passes it
down to the OptionModel. That doesn't feel right.


why don't you use java's Locale locale.getDisplayCountry(displayLocale) ?
so you would not need the message-catalog...

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



cannot find net.sf.tacos.ajax.components.ProgressBar

2008-02-10 Thread asiancool
i trying to find source code for this
http://opencomponentry.com:8080/tacos/forms/UploadProgressBar.html . may i know
where is it located ? i cannot find it inside tacos-project-4.1.1-src .  


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



Re: T5 Localized Select

2008-02-10 Thread Harald Geritzer

Olivier Jacquet schrieb:

Yes, I figured out that much by now (I'm not that experienced with Java).

Yet, I think it is a feasable use case that you would want access to a 
message catalog in an OptionModel, no?


well, guess you could write your own SelectModel, create it in your page and pass the messagecatalog 
as a

constructor parameter to the SelectModel

class MyPage {

@Inject
private Messages messages;

private MyLocaleModel myLocaleModel;


void onPrepare() {

myLocaleModel = new MyLocaleModel(messages);

}


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



Re: T5 Localized Select

2008-02-10 Thread Olivier Jacquet

Yes, I figured out that much by now (I'm not that experienced with Java).

Yet, I think it is a feasable use case that you would want access to a 
message catalog in an OptionModel, no?




Harald Geritzer wrote:

Now, when you @Inject the messages in the OptionModel it is null when
you try to access it in getLabel() and I was wondering if that is
intended? Now I have to pass the catalog from my wrapper component
(SelectCountry) with its own catalog to my SelectModel which passes it
down to the OptionModel. That doesn't feel right.


why don't you use java's Locale locale.getDisplayCountry(displayLocale) ?
so you would not need the message-catalog...

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




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



Re: cannot find net.sf.tacos.ajax.components.ProgressBar

2008-02-10 Thread Andreas Andreou
That's from tacos-4.0 which supported Tapestry-4.0

On Feb 10, 2008 4:32 PM, asiancool [EMAIL PROTECTED] wrote:
 i trying to find source code for this
 http://opencomponentry.com:8080/tacos/forms/UploadProgressBar.html . may i 
 know
 where is it located ? i cannot find it inside tacos-project-4.1.1-src .


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





-- 
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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



T5 Localized Select

2008-02-10 Thread Olivier Jacquet

Hello,


I'm trying to build a select component which allows you to select a 
country. The labels would be the country names and the values the ISO 
codes for the country. The catch is that I want the country names 
displayed in the current locale.


Now, when you @Inject the messages in the OptionModel it is null when 
you try to access it in getLabel() and I was wondering if that is 
intended? Now I have to pass the catalog from my wrapper component 
(SelectCountry) with its own catalog to my SelectModel which passes it 
down to the OptionModel. That doesn't feel right.


Wouldn't it be nice to be able to access the Messages from within the 
OptionModel and get access to the resources from the wrapper component?



Best regards,
Olivier

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



Re: T5: ActionLink/Zone components inside a loop

2008-02-10 Thread Adriaan Joubert
Hi,

anybody had any luck with this? I tried

t:actionlink zone=${zoneId}Show/t:actionlink
t:zone visible=false t:id=${zoneId} context=${id}
/t:zone

But get

Component id '${zoneId}' is not valid; component ids must be valid Java
identifiers: start with a letter, and consist of letters, numbers and
underscores.

So it looks as if only literal values are accepted here?

And how do I deal with the events? The zone ids are constructed dynamically,
so I do not know what they will be when writing the code. I was hoping that
I could deal with this in an

void onEvent()

but I cannot get any context passed into this, so I do not know which zone
I'm dealing with. If anybody had an example of zones in a loop that would be
great!

Thanks,

Adriaan




On Feb 9, 2008 10:18 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote:

 Ajax constructs go outside of Tapestry's understanding of the page
 construction.  It relies upon the developer to generate unique zone
 ids.

 In your situation, I would have the setItem() method generate a unique
 zone id as a side effect and expose that as a proprty used by both the
 ActionLink and the Zone.

 On Feb 8, 2008 11:40 PM, Travis McLeskey [EMAIL PROTECTED] wrote:
  When an ActionLink and Zone appear together in a loop like this:
 
  t:loop source=items value=item
 t:actionlink zone=myzonego!/t:actionlink
 t:zone t:id=myzonein the zone?/t:zone
 br /
  /t:loop
 
  Clicking the go! link from any iteration only affects the Zone from
  the first iteration. How do I connect each ActionLink to its
  corresponding Zone? I tried injecting the Zone into the java class and
  then using zone=${thezone.id} in the actionlink, but then each
  ActionLink was connected to the Zone from the *previous* iteration.
 
  Thanks!
  Travis
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



 --
 Howard M. Lewis Ship

 Creator Apache Tapestry and Apache HiveMind

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




Re: T5: ActionLink/Zone components inside a loop

2008-02-10 Thread Olivier Jacquet

Not sure if this helps but I think that what you want is actually:

t:actionlink t:zone=prop:zoneIdShot/t:actionlink

Regards,
Olivier


Adriaan Joubert wrote:

Hi,

anybody had any luck with this? I tried

t:actionlink zone=${zoneId}Show/t:actionlink
t:zone visible=false t:id=${zoneId} context=${id}
/t:zone

But get

Component id '${zoneId}' is not valid; component ids must be valid Java
identifiers: start with a letter, and consist of letters, numbers and
underscores.

So it looks as if only literal values are accepted here?

And how do I deal with the events? The zone ids are constructed dynamically,
so I do not know what they will be when writing the code. I was hoping that
I could deal with this in an

void onEvent()

but I cannot get any context passed into this, so I do not know which zone
I'm dealing with. If anybody had an example of zones in a loop that would be
great!

Thanks,

Adriaan




On Feb 9, 2008 10:18 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote:


Ajax constructs go outside of Tapestry's understanding of the page
construction.  It relies upon the developer to generate unique zone
ids.

In your situation, I would have the setItem() method generate a unique
zone id as a side effect and expose that as a proprty used by both the
ActionLink and the Zone.

On Feb 8, 2008 11:40 PM, Travis McLeskey [EMAIL PROTECTED] wrote:

When an ActionLink and Zone appear together in a loop like this:

t:loop source=items value=item
   t:actionlink zone=myzonego!/t:actionlink
   t:zone t:id=myzonein the zone?/t:zone
   br /
/t:loop

Clicking the go! link from any iteration only affects the Zone from
the first iteration. How do I connect each ActionLink to its
corresponding Zone? I tried injecting the Zone into the java class and
then using zone=${thezone.id} in the actionlink, but then each
ActionLink was connected to the Zone from the *previous* iteration.

Thanks!
Travis


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





--
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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






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



Re: T5: ActionLink/Zone components inside a loop (solved, sort of)

2008-02-10 Thread Travis McLeskey
(I wasn't subscribed to the list, so I'm sorry I'm not quoting the  
rest of the thread here.)


I ran into the same problem as Adriaan: it wouldn't let me use a  
property expansion for the zone's id attribute. The only way around  
this that I found was to create my own MyZone component (based on  
Tapestry's Zone.java) and add a customId attribute. Then, in  
MyZone.beginRender(), I replaced this:


_clientId =  
_pageRenderSupport.allocateClientId(_resources.getId());


with something like:

if( _resources.isBound(customId) )
_clientId = _customId;
else
_clientId =  
_pageRenderSupport.allocateClientId(_resources.getId());


Then, I made my loop look more like this:

t:loop source=items value=item
 t:actionlink zone=myzone:${item.id}go!/t:actionlink
 t:myzone customid=myzone:${item.id}in the zone?/t:zone
 br /
/t:loop

Which worked quite nicely, and it let me make a few other tweaks to  
how the Zone was rendered, like making it a span instead of a div.




However, that was only the first Zone-related hurdle. The next was  
that I couldn't find any examples in the documentation of how to  
actually provide the new content for the zone when the user clicks the  
link. After a lot of time digging through the code (and learning  
javascript!), I found the (or at least *a*) way to do it. I added this  
method to my class:


public Object onActionFromUpdatezone(final long id) {
JSONObject result = new JSONObject();
result.put(content, The new content for the Zone's div.  
Fresh from the server!);

return result;
}

(Note: I gave the ActionLink an id: updatezone)



The next problem was that Zones in Tapestry currently can't do much  
other than query the server for new content, put that content in the  
div, and then call your show or update methods, if you specified  
them. You can't have it do something other than hit the server when  
the link is clicked, and you can't process the content before putting  
it in the div. Well, at least you can't do these things without the  
magic of javascript. My eventual solution is probably going to break  
in some future release of Tapestry, and it may provoke some frowns,  
but I circumvented all of the Zone-specific javascript code in  
Tapestry be redefining Tapestry.initializeZones. The javascript below  
is for an ActionLink that works as an expand/collapse button for the  
Zone. The first time you expand the zone, it downloads the content  
from the server and stores it in memory. After that, it doesn't need  
to hit the server again. Note that this code doesn't support the inner  
t-zone-update div that Tapestry's built-in javascript supports.



MyObj = {
  linkZone: function (link, zone) {
zone = $(zone);
link = $(link);
var expanded = false;
var origHTML = zone.innerHTML;
var fullHTML;

link.onclick = function(event) {
  if( expanded ) {
zone.innerHTML = origHTML;
link.innerHTML = expand;
expanded = false;
  } else {
if( !zone.everPopulated ) {
  var successHandler = function(transport) {
var response = transport.responseText;
fullHTML = eval(( + response + )).content;
zone.innerHTML = fullHTML;
  };
  var request = new Ajax.Request(link.href, { onSuccess :  
successHandler });

  zone.everPopulated = true;
} else {
  zone.innerHTML = fullHTML;
}
link.innerHTML = collapse
expanded = true;
  }
  return false;
};
  }
};

Tapestry.initializeZones = function(zoneSpecs, linkSpecs) {
  $A(linkSpecs).each(function (spec)
  {
  MyObj.linkZone(spec[0],spec[1]);
  });
};



Hope that helps!
Travis





On Feb 8, 2008, at 11:40 PM, Travis McLeskey wrote:


When an ActionLink and Zone appear together in a loop like this:

t:loop source=items value=item
 t:actionlink zone=myzonego!/t:actionlink
 t:zone t:id=myzonein the zone?/t:zone
 br /
/t:loop

Clicking the go! link from any iteration only affects the Zone  
from the first iteration. How do I connect each ActionLink to its  
corresponding Zone? I tried injecting the Zone into the java class  
and then using zone=${thezone.id} in the actionlink, but then each  
ActionLink was connected to the Zone from the *previous* iteration.


Thanks!
Travis




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



how to redirect to another page from a component?

2008-02-10 Thread Travis McLeskey
In a page, you can listen for the activate event and, for example,  
if the user doesn't have permission to view that page, you can return  
a value (Page, Class, String, etc.) that triggers a redirect to  
another page.


Is it possible to do the same when a component is loading/rendering?  
Components don't receive the activate event, and I haven't had any  
luck returning a page object from setupRender() and beginRender().


Thanks,
Travis


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



Re: how to redirect to another page from a component?

2008-02-10 Thread Dapeng

what i am doing is

@Inject
private Response response;

boolean beginRender(){

   if( isRedirectNeeded() ) {
try { response.sendRedirect() } catch (Exception e) {}
return false;
   }

}



Travis McLeskey wrote:
In a page, you can listen for the activate event and, for example, 
if the user doesn't have permission to view that page, you can return 
a value (Page, Class, String, etc.) that triggers a redirect to 
another page.


Is it possible to do the same when a component is loading/rendering? 
Components don't receive the activate event, and I haven't had any 
luck returning a page object from setupRender() and beginRender().


Thanks,
Travis


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




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



Re: how to redirect to another page from a component?

2008-02-10 Thread Travis McLeskey

Ah, thanks, that works for me. Here's what I did:

@Inject
private Response response;

@Inject
private LinkFactory linkFactory;

public Object beginRender() throws IOException {
if( isLoginNeeded() )
 
response.sendRedirect( linkFactory.createPageLink(Login, true) );

return true;
}

I wish there were a cleaner way, but that'll do.

Thanks,
Travis



On Feb 10, 2008, at 9:06 PM, Dapeng wrote:


what i am doing is

@Inject
private Response response;

boolean beginRender(){

  if( isRedirectNeeded() ) {
   try { response.sendRedirect() } catch (Exception e) {}
   return false;
  }

}



Travis McLeskey wrote:
In a page, you can listen for the activate event and, for  
example, if the user doesn't have permission to view that page, you  
can return a value (Page, Class, String, etc.) that triggers a  
redirect to another page.


Is it possible to do the same when a component is loading/ 
rendering? Components don't receive the activate event, and I  
haven't had any luck returning a page object from setupRender() and  
beginRender().


Thanks,
Travis


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




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




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



Re: how to redirect to another page from a component?

2008-02-10 Thread Dapeng

besides the similarity

i guess ur beginRender should return false for redirect

refering to the state diagram

http://tapestry.apache.org/tapestry5/tapestry-core/guide/rendering.html


Travis McLeskey wrote:

Ah, thanks, that works for me. Here's what I did:

@Inject
private Response response;

@Inject
private LinkFactory linkFactory;

public Object beginRender() throws IOException {
if( isLoginNeeded() )
response.sendRedirect( linkFactory.createPageLink(Login, 
true) );

return true;
}

I wish there were a cleaner way, but that'll do.

Thanks,
Travis



On Feb 10, 2008, at 9:06 PM, Dapeng wrote:


what i am doing is

@Inject
private Response response;

boolean beginRender(){

  if( isRedirectNeeded() ) {
   try { response.sendRedirect() } catch (Exception e) {}
   return false;
  }

}



Travis McLeskey wrote:
In a page, you can listen for the activate event and, for example, 
if the user doesn't have permission to view that page, you can 
return a value (Page, Class, String, etc.) that triggers a redirect 
to another page.


Is it possible to do the same when a component is loading/rendering? 
Components don't receive the activate event, and I haven't had any 
luck returning a page object from setupRender() and beginRender().


Thanks,
Travis


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




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




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




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



Re: how to redirect to another page from a component?

2008-02-10 Thread Travis McLeskey
Unfortunately, for me, returning false produced this nasty-looking  
stack trace:


[ERROR]  
org.apache.tapestry.internal.services.DefaultRequestExceptionHandler  
Processing of request failed with uncaught exception: Page Start did  
not generate any markup when rendered. This could be because its  
template file could not be located, or because a render phase method  
in the page prevented rendering.
java.lang.RuntimeException: Page Start did not generate any markup  
when rendered. This could be because its template file could not be  
located, or because a render phase method in the page prevented  
rendering.
	at  
org 
.apache 
.tapestry 
.internal 
.services 
.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:58)
	at  
$ 
PageMarkupRenderer_11806dbfeb2 
.renderPageMarkup($PageMarkupRenderer_11806dbfeb2.java)
	at  
org 
.apache 
.tapestry 
.internal 
.services 
.PageResponseRendererImpl 
.renderPageResponse(PageResponseRendererImpl.java:56)

.
.
.

I don't understand, but I think I'll just return void from the method  
instead.


Travis


On Feb 10, 2008, at 9:54 PM, Dapeng wrote:


besides the similarity

i guess ur beginRender should return false for redirect

refering to the state diagram

http://tapestry.apache.org/tapestry5/tapestry-core/guide/ 
rendering.html



Travis McLeskey wrote:

Ah, thanks, that works for me. Here's what I did:

   @Inject
   private Response response;

   @Inject
   private LinkFactory linkFactory;

   public Object beginRender() throws IOException {
   if( isLoginNeeded() )

response.sendRedirect( linkFactory.createPageLink(Login, true) );

   return true;
   }

I wish there were a cleaner way, but that'll do.

Thanks,
Travis



On Feb 10, 2008, at 9:06 PM, Dapeng wrote:


what i am doing is

@Inject
private Response response;

boolean beginRender(){

 if( isRedirectNeeded() ) {
  try { response.sendRedirect() } catch (Exception e) {}
  return false;
 }

}



Travis McLeskey wrote:
In a page, you can listen for the activate event and, for  
example, if the user doesn't have permission to view that page,  
you can return a value (Page, Class, String, etc.) that triggers  
a redirect to another page.


Is it possible to do the same when a component is loading/ 
rendering? Components don't receive the activate event, and I  
haven't had any luck returning a page object from setupRender()  
and beginRender().


Thanks,
Travis


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




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




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




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




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