Component only invokes javascript correctly from BeginRender

2009-11-02 Thread Jonathan O'Connor

Hi,
I have a strange problem. One of my colleagues found a javascript 
library ajaxtabs from DynamicDrive.com, and he created a small component 
wrapping its usage. His code makes use of @BeginRender to generate the 
html. The last part of this generated html is a little script that 
invokes the ajax tabs javascript.


I wanted to change the BeginRender code into MyTabs.tml instead.
Naturally, everything looks fine, and the generated html looks the same 
as that explicitly written by the BeginRender method, but the java 
script does not work properly. I suspect that it is throwing an 
exception while running.


I also tried setting the javascript to run on DOMLoaded(), but that does 
not work at all, from BeginRender, or .tml.


Is there any reason why it should work correctly with BeginRender 
method, but not a .tml file?


Ciao,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: GridSortModel

2009-07-31 Thread Jonathan O'Connor

Hi,
in your tml file, provide an override for the usernamecell. You will 
need to provide 2 attributes, username and usernameUppercase. Or you can 
modify the DataSourceModel and add a usernameUppercase. The trick is to 
tell the grid to use the usernameUppercase as the column data, but then 
in the tml cell override to print the username.


Hope this helps. Sorry that I can't look up my own code at the moment. 
But look at the grid component documentation.

Ciao,
Jonathan

On 31/07/2009 05:21, ppetrou wrote:

I am using a Grid component to display the fields of a User and when clicking
on the USERNAME column header the default behavior is to sort a the users by
name(case sensitive). However, I want the sorting to take place in a
non-case sensitive manner. I tried to do this with the GridSortModel but I
can't figure out if I need to implement a Comparator or something.

Any pointers?
   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Changing Sort on Grid Column

2009-07-07 Thread Jonathan O'Connor

Hi,
I have a Grid with a string column displaying a date. I want this column 
to be of String type because of my automatic code to generate a CSV file 
from the grid. However, if I sort the column, it is sorted using 
alphabetic ordering, thus 25-12-2001 comes after 01-01-2009.


Is there a way to change this? From what I can see the GridSortModel 
provides a ColumnSort enum, but I can't see how to supply a comparator. 
Is this possible?


As a workaround, I can leave the column as a Date, and then supply a 
overridden myDatecell block. But I will also have to modify my CSV 
generator.


Ciao,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Inheriting from Component Classes

2009-07-06 Thread Jonathan O'Connor

Hi,
I'm pretty sure what the answer is, but can someone confirm that it is 
not possible to use java inheritance to extend a component class?


What I'm trying to do is add a CSV Download button to a Grid, preferably 
aligned to the right of the table. I can override the .tml files of the 
existing components, but I would prefer to not have to duplicate all the 
java code from the Grid class.


I considered using a mixin, but that does not allow the mixin to create 
other components. Or have I got that wrong?


I feel this is a pain point for Tapestry. Is there any work going on to 
improve this area? Of course, for smaller components, I wouldn't worry 
about it, but the Grid component is large, and has lots of useful 
functionality I don't want to duplicate. One possibility, specific to 
Grid would be to add more block parameters that could be used to extend 
the layout of the Grid. Would this work for me?


Thanks for any advice,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Inheriting from Component Classes

2009-07-06 Thread Jonathan O'Connor

Thiago,
I was just about to write my solution up in the Wiki, but I'm having 
problems getting my password to work :-(


Anyway, yes, you're quite right, you can extend component classes.

My main job was to supply a GridEx.tml where I added my special link:

div class=t-data-grid 
xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;


table t:id=table
thead
tr class=GridExHeader
td colspan=${pagerCols}div t:id=pagerTop//td
td class=t-lasta t:type=CSVImageLink t:source=inherit:source 
t:model=inherit:model t:filename=literal:kunden/a/td

/tr
tr t:id=columns/
/thead
tbody
tr t:id=rows/
/tbody
/table

div t:id=pagerBottom/

t:block
div t:id=pager/
/t:block

t:block id=emptyThere is no data to display./t:block
/div

I added getPagerCols to the GridEx class, and bingo, it all worked!

Thanks for the ideas, but in this case, I think it was easier to just 
provide a tml file.


Ciao,
Jonathan
On 06/07/2009 15:45, Thiago H. de Paula Figueiredo wrote:

n Mon, Jul 6, 2009 at 10:20 AM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Hi,
 


Hi!

   

I'm pretty sure what the answer is, but can someone confirm that it is not
possible to use java inheritance to extend a component class?
 


Yes, it is.

   

What I'm trying to do is add a CSV Download button to a Grid, preferably
aligned to the right of the table. I can override the .tml files of the
existing components, but I would prefer to not have to duplicate all the
java code from the Grid class.
 


Tapestry built-in components have most of their method package-private
or private for backward compatibility, so subclassing them isn't the
answer most of the time.

   

I considered using a mixin, but that does not allow the mixin to create
other components. Or have I got that wrong?
 


Just Tapestry itself can instantiate components, so I guess you got
something wrong here.
And I think a mixin it's the best way of doing what you want:
@InjectContainer the Grid, use Grid.getGridDataSource(),
Grid.getDataModel() (to get the BeanModel), maybe
Grid.getCurrentPage(), create an EventLink and return a StreamResponse
in its handler method. Take a look at the Autocomplete mixin source
for inspiration. No need for subclassing here.

Another example, but more complex:
http://ars-machina.svn.sourceforge.net/viewvc/ars-machina/tapestry-crud/branches/1.1/src/main/java/br/com/arsmachina/tapestrycrud/mixins/TreeGrid.java?revision=594view=markup.
It is a mixin that provides a tree-like visualization to a Grid.

   


Re: [t5.0.18] Is it possible to nested normal jsp/html content into one layout component region?

2009-03-13 Thread Jonathan O'Connor

Zenberg,
I added Tap5 pages to an existing struts 1 application. The trick is to 
reimplement a login page (I presume you have a login page) as a T5 page, 
and then you can initialize the JSP session variables you need for 
working together. You will also have to be careful generating links from 
JSP to T5 and vice versa. If you do make changes to your layout, then 
you will need to reimplement them in a JSP as well.


Search this list for integrating struts with T5 (also look for Kent 
Tong, who came up with the original solution for T4).

Ciao,
Jonathan

On 13/03/2009 04:48, Zenberg Ding wrote:


But that's only put them together without runtime error. each of them 
is working standalone, so it's not really working together...




As far as I know, you can have Tapestry pages and JSP pages and 
Struts actions in the same application working together, but you 
cannot have JSP and Tapestry templates in the same page. They're 
completely different.




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: generics and pages, components and edit blocks

2009-03-09 Thread Jonathan O'Connor
Although you can't use generics directly, I presume you can define a 
subclass that inherits from a given generic superclass.

For instance,
class CrudPageT {
// Stuff with T
}

class CustomerCrud extends CrudPageCustomer {
}

Would this work? I suppose if you used a generic service, then you would 
have to also instanciate it before using it:

class CrudServiceT { /* stuff */ }
abstract class CrudPageT {
protected abstract CrudServiceT getCrudService();
}

class CustomerCrudService extends CrudServiceCustomer { }
class CustomerCrudPage extends CrudPageCustomer {
@Inject
private CustomerCrudService service;
protected CustomerCrudService getCrudService() { return service; }
}

Jonathan
On 09/03/2009 02:35, Luther Baker wrote:

Yes.

Maybe Tapestry 6 :)

Given that the language keeps changing/moving forward, this seems like an
odd thing to simply leave the user with ... I would guess that Templates,
Components, Pages ... and the way we setup Services in AppModule would
eventually want to consider techniques that wish to leverage Generics.
Obviously, registering something like DataServiceMovie.class is illegal
Java - so it may take a creative approach.

Obviously from a page/component standpoing, there'd have to be a new
convention for such beasts. Naively:

note/EditBlock_Note
idea/EditBlock_Idea

And Services (interfaces and implementations) would be a completely
different problem ... and with things like type erasure and backwards
compatibility ... it all strikes me as an interesting issue.

-Luther



On Sun, Mar 8, 2009 at 6:55 PM, Thiago H. de Paula Figueiredo
thiag...@gmail.com  wrote:

   

Em Sun, 08 Mar 2009 15:46:19 -0300, Luther Bakerlutherba...@gmail.com
escreveu:

  Is there anyway to use generics as pages, components or edit blocks?
 
No, because Tapestry uses the class name as URL.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


 


   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Grid: multiple tr within grid row

2009-02-24 Thread Jonathan O'Connor

Jason,
I wanted to add onclick, onmouseover and onmouseout to the rows in my 
grid, and due to some timing issues with JavaScript enhancement (it 
could take 3-4 seconds before the JS was loaded after the browser 
displayed the HTML), I went with DOM rewriting. Here's a sample of my 
code. You can probably do the same, by adding tr elements to the DOM tree.


First, I wrote a little utility class that should be enhanced to 
something similar to the $$() Prototype method. My version just finds 
the first matching node.


package org.jonathan.t5web;

import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.dom.Node;
import org.apache.tapestry5.ioc.internal.util.Defense;

public class ElementFinder
{
private static interface Finder {
Node search(Node root);
}

private static class IdFinder implements Finder {
private String id;

public IdFinder(String id) {
this.id = id;
}

public Element search(Node root) {
return ((Element)root).getElementById( id );
}
}

private static class IndexFinder implements Finder {
private int index;

public IndexFinder(int index) {
this.index = index;
}

public Node search(Node root) {
return root.getChildren().get( index );
}
}

private static class TagFinder implements Finder {
private String tag;

public TagFinder(String tag) {
this.tag = tag;
}

public Element search(Node root) {
return ((Element)root).find( tag );
}
}

public Node find(String selector, Node rootElement) {
Defense.notBlank(selector, selector);
Defense.notNull( rootElement, rootElement );

String[] selectors = selector.split(   );
Node search = rootElement;
for (String s : selectors) {
Finder finder = parseSelector( s );
search = finder.search( search );
if (search == null) {
return null;
}
}
return search;
}

/**
 * Returns true if the selector is an id, e.g. #customerSearch
 * @param selector
 */
private boolean isIdSelector( String selector ) {
return selector.startsWith( # );
}

IdFinder buildIdFinder( String idSelector ) {
return new IdFinder(idSelector.substring( 1 ));
}

/**
 * Returns true if the selector is an id, e.g. #customerSearch
 * @param selector
 */
private boolean isIndexSelector( String selector ) {
return selector.startsWith( [ )  selector.endsWith( ] );
}

IndexFinder buildIndexFinder(String indexSelector) {
return new IndexFinder(Integer.parseInt( 
indexSelector.substring( 1, indexSelector.length() - 1 ) ));

}

Finder parseSelector(String selector) {
if (isIdSelector( selector )) {
return buildIdFinder( selector );
}

if (isIndexSelector( selector )) {
return buildIndexFinder( selector );
}

if (isTagSelector( selector )) {
return buildTagFinder( selector );
}

throw new IllegalArgumentException(selector +  is not an id, 
tag or index);

}

Finder buildTagFinder( String selector )
{
return new TagFinder( selector );
}

private boolean isTagSelector( String selector )
{
return !selector.startsWith( # )  !selector.startsWith( [ 
)  !selector.endsWith( ] );

}
}

Now, you need to provide an afterRender method to do the DOM rewriting:

void afterRender(MarkupWriter writer) {
Document doc = writer.getDocument();
if (doc == null) {
_logger.info( writer.getDocument( ) is null );
return;
}

ElementFinder finder = new ElementFinder();
Node tbody = finder.find( #customerTable tbody, 
doc.getRootElement() );

if (tbody == null) {
_logger.info( writer.getDocument( 
).getElementById(customerTable).find(tbody) is null );

return;
}
String prefixUrl = generateCustomerRowLinkEventUrlPrefix();
_rowIndex = 0;
for (Node node : tbody.getChildren()) {
Element tr = (Element)node;
Node custId = finder.find( [1] [0], tr );
tr.attribute( onclick, doCustomerTableRowClick(' + 
prefixUrl + custId.toString() + '); );
tr.attribute( onmouseover, this.className = 
'DataTableEntryMouseOver'; );
tr.attribute( onmouseout, this.className = ' + 
getRowClass() + ';);

_rowIndex++;
}
}

Hope this helps,
Jonathan
On 24/02/2009 01:40, Jason Tan wrote:

Hi,

I'd like to render multipletr  elements within the same grid row.
Searching this mailing list seems to come up with a combination of
subclassing Grid and GridRows (i.e.

Re: Using Tapestry 5 IOC in tapestry 4 pages.

2009-02-16 Thread Jonathan O'Connor

Travis,
I don't know Tap 4, so, I don't know if the approach I will describe can 
work.


I was able to integrate Tapestry 5 with Struts 1. I followed the 
approach described by Kent Tong in his E-Book on Tapestry 4.
1. The main problem is setting up the session. As struts is a thin layer 
on top of the Servlet API, this is fairly easy. I reimplemented our 
login page in Tapestry 5, and part of that creates the old struts 
session object in the HttpSession. Tapestry 5, itself, creates its own 
session objects.
2. Any links from a Tapestry 5 page to a struts page and vice versa, are 
basically hard-coded.




On 14/02/2009 04:22, Travis Romney wrote:

I've been upgrading an application from tapestry 4 to tapestry 5.
The application is quite large, so we're just migrate a few pages here and
there.
I've created some tapestry 5 services that depend on a Request.
I would like to be able to inject these services into a few tapestry 4
pages,
as we migrate.

   
You might want to rewrite your T5 services to use HttpServletRequest 
instead of Request. Then you could manually instanciate those objects in 
your T4 components.


Hope these ideas help you,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



AppModule conventions

2009-02-13 Thread Jonathan O'Connor

Hi,
I've been looking for documentation about how the AppModule class works. 
Sadly, I have only found a few examples of bind/contribute and build 
methods, but nothing that explains when and what to use.


I would like to know:
1. Which methods should be static and which non-static? Does it matter?
2. If I write a method contributeXXX() what does the XXX refer to? A 
Service? Also, why do some contribute methods take a Map, and others a 
list? Who decides?
3. Are there other prefixes that are magic, apart from bind, contribute 
and build?


If I missed this in the standard documentation, then apologies, and a 
link to where to look is fine,

Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: AppModule conventions

2009-02-13 Thread Jonathan O'Connor

Robert,
thanks, somehow I missed this, and it didn't show up in a google search 
either.

Jonathan

On 13/02/2009 14:05, Robert Zeigler wrote:

Hi,
The AppModule is an IOC module, so, I would start with:

I would start at 
http://tapestry.apache.org/tapestry5/tapestry-ioc/index.html.


And read the Modules, Services, Decorators and Configuration 
pages, at a bare minimum.


Robert

On Feb 13, 2009, at 2/137:38 AM , Jonathan O'Connor wrote:


Hi,
I've been looking for documentation about how the AppModule class 
works. Sadly, I have only found a few examples of bind/contribute and 
build methods, but nothing that explains when and what to use.


I would like to know:
1. Which methods should be static and which non-static? Does it matter?
2. If I write a method contributeXXX() what does the XXX refer to? 
A Service? Also, why do some contribute methods take a Map, and 
others a list? Who decides?
3. Are there other prefixes that are magic, apart from bind, 
contribute and build?


If I missed this in the standard documentation, then apologies, and a 
link to where to look is fine,

Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [T5] Internationalizing included js

2009-02-11 Thread Jonathan O'Connor

Alex,
according to Thiago, you can have string substitution in the javascript:
THIAGO
Another solution is to put a Tapestry expression expansion inside the 
Javascript code:


Page class:

public Link getEventLink() {
return componentResources.createXXXLink(parameters);
}

Template:

window.location.href='${eventLink}' + this.cells[1].textContent;
THIAGO

So presumably, you can use ${message:some-message-key}, and it will be 
translated properly.


I haven't tried this myself, so please let me know if this works.
Ciao,
Jonathan
On 11/02/2009 06:01, Alex Kotchnev wrote:

What is the best method for internationalizing strings inside of .js files
included using the @IncludeJavaScript annotation ? I've looked around and I
see that I can use the regular message catalog and string substitution (e.g.
addScript(String format, Object... arguments);) if the script is attached to
a particular element or something similar. However, if I am including the js
using the @IncludeJavaScript annotation, what is the best approach ? I've
tried (and it works great) to add localized js assets (e.g. foo.js,
foo_bg.js, etc) and the localization works nicely. However, my little hangup
with that is the actual code inside of the js is the same, just the messages
are different. Can I somehow configure T5 to process the js (just like a tml
file) and do message substitution inside (e.g. so that I can use expansions
like ${message:foo-message} inside the js file).

I guess I can also include the js inline in the .tml and the message catalog
substitution would work.

Cheers,

Alex K

   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Hibernate ID

2009-02-10 Thread Jonathan O'Connor

Uli,
Using Object for key fields is a standard micro pattern in JPA and 
Hibernate. Of course, the DB does not want to save null as a key field 
value, but the most people get the entity manager to auto-generate keys 
for their objects.


By leaving the key as null, the entity manager knows that it needs to 
persist the object, generating a key for it. This is a handy pattern, 
when you want to create a parent object with several children, and then 
persist the whole object tree in one call (otherwise, you would have to 
persist the tree, one object at a time, from the bottom up - Yikes!). 
JPA/Hibernate can only do this if it knows what a null key value is, and 
in Java that is of course, null. I think (from memory) you can define a 
specific value as a null, so you could use an int or a long as a key 
field type, and then specify, for example, -999, as the null value. 
Then, you have to set the key field to -999 somewhere, and this is all 
too much work for most people, therefore, they use Object key field values!


Ciao,
Jonathan
On 10/02/2009 08:08, Ulrich Stärk wrote:

Thiago H. de Paula Figueiredo schrieb:
Em Mon, 09 Feb 2009 22:35:52 -0300, Luther Baker 
lutherba...@gmail.com escreveu:



Simply stated, I'm asking about the two orthogonal choices: (native vs
object, range or size)
Is an int preferred to an Integer? Is there a compelling argument 
for either native or Object?


I guess that you mean primite when you mean native.
Native types in Java can't have null values, so, for primary key 
properties, a Integer is a much better fit than an int.


Why is that? I couldn't imagine a case where you want your primary key 
value to be NULL (apart from the fact that I don't know any DBMS that 
allows that).


Uli

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Dynamic Variables in Asset declarations

2009-02-09 Thread Jonathan O'Connor

Dave,
thinking out of the box, can you instead set up some server cron job to 
copy the css files over from the other web server to your server. Would 
that make it easier?

Jonathan

On 08/02/2009 14:07, Dave Greggory wrote:

So, tell me whether I have this straight.

In order to create Asset instances based on URL (actual asset CSS files 
residing on a completely different web server = CDN) like below:

@Inject
@Path(paramasset:${server_host}${css_root}/commons.css)
private Asset myCommonAsset;

server_host varies from environment to environment (QA/staging/production).
css_root varies from request to request as it depends on request params 
(basically different users have different themes).

To do this, I would need to implement a new Asset Factory, an Asset Binding, an 
Asset Binding Factory and an Asset Resource. Is that correct?

Do I really need the binding and binding factory? Can I implement the above functionality 
without the new paramasset domain?

I tried stepping through the Classpath Asset and Context Asset factories and 
bindings while debugging, but it was little confusing. Can anyone clarify to me 
how all these fit together?

Thanks,
Dave



- Original Message 
From: Dave Greggorydavegregg...@yahoo.com
To: Tapestry usersusers@tapestry.apache.org
Sent: Wednesday, February 4, 2009 12:27:37 PM
Subject: Re: Dynamic Variables in Asset declarations

That could be an option but I thought the beauty of using RenderSupport is that whenever a 
sub-component add a style sheet to it, it will always go in thehead  section of the 
page. So each component would have the facility to provide its own stylesheets that will be 
picked up by the containing page and included in the page'shead  section.



- Original Message 
From: Thiago H. de Paula Figueiredothiag...@gmail.com
To: Tapestry usersusers@tapestry.apache.org
Sent: Wednesday, February 4, 2009 12:58:03 PM
Subject: Re: Dynamic Variables in Asset declarations

Em Wed, 04 Feb 2009 13:54:51 -0300, Dave Greggorydavegregg...@yahoo.com  
escreveu:

   

Your example may work, but it's not what I'm looking for because thelink  tag 
is hard coded in the TML.
 


Couldn't you generate the link tags in code instead of template? I guess you 
should consider the option of creating a templateless component to generate or 
not the link tags.

--Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



How can I modify the rendering of grid rows?

2009-02-09 Thread Jonathan O'Connor

Hi,
I would like to modify the way grid rows are rendered. I want add an 
onmouseout, onmouseover handlers to the tr tags.


I suppose I could do a load of cut and paste, and reimplement the grid, 
but is there an easier way?


Ciao,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How can I modify the rendering of grid rows?

2009-02-09 Thread Jonathan O'Connor

Thiago,
The mouse out and over handlers change the background color, as the user 
moves teh mouse over the table. I also need to set the onclick of each 
td so it goes to a new page. I'll have a look at doing it the prototype 
way :-(. I suppose it really is the proper way to that.


I had another idea, that I could modify the DOM tree after rendering 
(say in cleanupRender) but I haven't seen any examples do this.


Ciao,
Jonathan

On 09/02/2009 18:27, Thiago H. de Paula Figueiredo wrote:
Em Mon, 09 Feb 2009 14:19:20 -0300, Jonathan O'Connor 
ninki...@eircom.net escreveu:



Hi,
I would like to modify the way grid rows are rendered. I want add an 
onmouseout, onmouseover handlers to the tr tags.


Rendering or adding behaviour? :)

I suppose I could do a load of cut and paste, and reimplement the 
grid, but is there an easier way?


If all you need is to change background colors and/or foreground 
colors, you can accomplish that just using CSS (all Grids are rendered 
as table class=t-data-grid and you can use the rowClass parameter 
to assign CSS classes to tr tags).


If you really need Javascript, try using Prototype to get any table 
with class=t-data-grid then iterate through the nested tr 
elements. ;)




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How can I modify the rendering of grid rows?

2009-02-09 Thread Jonathan O'Connor

Thiago,
I am most impressed with Prototype. I really like using $$(). Here's my 
code to add onmouseover, onmouseout and onclick handlers for a zebra 
striped table. Unfortunately, I have to support IE6, so I couldn't use 
:hover for the mouse over/out handlers.


Tapestry.onDOMLoaded(function() {
var mouseover = function(e) {
this.className = 'DataTableEntryMouseOver';
};

var click = function(e) {
// This location is sadly hardwired into the code - not very 
nice :-(

window.location.href='/onlinebanking-biwvp/CustomerSearch.customerId/' + 
this.cells[1].textContent;

};

$$('#customerTable tbody tr.DataTableEntryEven').each(function(elmt) {
Event.observe(elmt, 'mouseover', mouseover);
Event.observe(elmt, 'mouseout', function(ev) {
this.className = 'DataTableEntryEven';
});
Event.observe(elmt, 'click', click);
});

$$('#customerTable tbody tr.DataTableEntryOdd').each(function(elmt) {
Event.observe(elmt, 'mouseover', mouseover);
Event.observe(elmt, 'mouseout', function(ev) {
this.className = 'DataTableEntryOdd';
});
Event.observe(elmt, 'click', click);
});
});

Hope this helps the next person!
Jonathan

On 09/02/2009 18:52, Thiago H. de Paula Figueiredo wrote:
Em Mon, 09 Feb 2009 14:40:33 -0300, Jonathan O'Connor 
ninki...@eircom.net escreveu:



Thiago,
The mouse out and over handlers change the background color, as the 
user moves teh mouse over the table.


This can be done in CSS using the :hover pseudo-selector.

I also need to set the onclick of each td so it goes to a new page. 
I'll have a look at doing it the prototype way :-(. I suppose it 
really is the proper way to that.


That really needs Javascript, and it can be easily done with 
Prototype. I have almost no experience and I was able to do some DOM 
operations with Prototype in a short time frame. ;)


I had another idea, that I could modify the DOM tree after rendering 
(say in cleanupRender) but I haven't seen any examples do this.


A very nice place to learn how to deal with Javascript issues in 
Tapestry is 
http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained.




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How can I modify the rendering of grid rows?

2009-02-09 Thread Jonathan O'Connor

Thiago,
yes, I know about ComponentResources.createXXXLink(), but how do I sneak 
it into the JavaScript? I guess I have to generate some special java 
script in afterRender. I'm sure I saw code like in the WIKI.


Ciao,
Jonathan

On 10/02/2009 01:22, Thiago H. de Paula Figueiredo wrote:
Em Mon, 09 Feb 2009 21:09:06 -0300, Jonathan O'Connor 
ninki...@eircom.net escreveu:



Thiago,


Hello, Jonathan!


I am most impressed with Prototype. I really like using $$().


Me too. As I can see, you quickly learned enough Prototype in a couple 
hours to do what you needed. :)


Here's my code to add onmouseover, onmouseout and onclick handlers 
for a zebra striped table. Unfortunately, I have to support IE6, so I 
couldn't use :hover for the mouse over/out handlers.


In other thread in this mailing there were people complaining about 
Internet Explorer. Add me to the list of IE haters. :(


On the other hand, we thank you for sharing your code with us. :) What 
about adding this to the Tapestry wiki?


Just one little Prototype advice: instead of using this to refer to 
the HTML element passed as an argument, use the first parameter 
(typically named e). Instead of doing this.className = something, 
you can use e.addClassName(something). All elements returned by 
Prototype are extended. This means that they have all methods listed 
here: http://www.prototypejs.org/api/element. This will make your 
Javascript code a little more elegant. ;) Something like (not tested):


$$('#customerTable tbody tr.DataTableEntryEven').each(function(elmt) {
  Event.observe(elmt, 'mouseover', mouseover);
  Event.observe(elmt, 'mouseout', function(ev) {
  ev.addClassName('DataTableEntryEven'); // --- example here
  });
  });


 var click = function(e) {
 // This location is sadly hardwired into the code - not very 
nice :-(
window.location.href='/onlinebanking-biwvp/CustomerSearch.customerId/' + 
this.cells[1].textContent;

 };


Use ComponentResources.createXXXLink() to create the link for you. ;)



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Protecting ActionLinks when using a Dispatcher.

2009-02-06 Thread Jonathan O'Connor

Thiago,
firstly, I assumed you meant Normal == the Tapestry Dispatcher, but 
my point is that the 4 Tapestry built-in Dispatchers (AssetDispatcher, 
ComponentEventDispatcher, PageRenderDispatcher and RootPathDispatcher) 
are no different to my JonathansFunkyDispatcher, and nor should they. 
Anyway, it seems Howard has a new interface in Tap 5.1.


BTW, after your comment about loading a page just to check the 
annotations, I went looking at the ComponentClassResolver. It has a neat 
method: resolvePageNameToClassName(String logicalPageName). Then I can 
ask a classloader for the class, and bingo! No more page instanciation.


Ciao,
Jonathan

On 06/02/2009 11:22, Thiago H. de Paula Figueiredo wrote:

On Thu, Feb 5, 2009 at 10:43 PM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Thiago,
 


Hi!

   

I guess you want the Class if your doing annotation based protection, and
the string if you have some sort of map.
 


You're right. My needs are different from yours. :)

   

But, as Daniel mentioned, you can
get a ComponentSource, and convert the string to a Class, so no problems
there.
 


This isn't the best way to do it because a component or page would be
instantiated just for the sake of knowing what page/component class.

   

The problem is deciding what a normally dispatched request is.
 


I could have chosen better words. When I said normal, I meant
dispatched by the Tapestry dispatcher. ;)

   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Protecting ActionLinks when using a Dispatcher.

2009-02-05 Thread Jonathan O'Connor

Daniel,
I was looking at this problem the other day, and you should look at the 
ComponentEventDispatcher. I think you need to first check if you get a 
matching page, and then check if you have an event. You can then extract 
the Pagename from the request path using that monster Reg exp. Sadly, 
this all relies on internal code :-(


Maybe there's a service for extracting the pagename from any request, 
but I guess that's not possible, because of the way people contribute 
Dispatchers.


Hope this helps,
Jonathan

On 05/02/2009 10:24, Daniel Jones wrote:

Hi there,

I have implemented and contributed a Dispatcher in order to secure access to
pages based on the users role.  This is similar to the tutorial on the wiki,
although I have used annotations, so I can attach @Secured(ROLE_ADMIN) to
the page class.  This works very well and the user is redirected to the
login page if they do not have the required privileges.

So my problem is that ActionLinks on these pages are unprotected.  If I was
a malicious user and somehow managed to guess the URL to one of these
actions, even though they are redirected to the login page by my Dispatcher,
the action is still invoked.

How do I protect these links, and is the same true for forms as well?  What
do I need to implement in order to catch these requests (RequestFilter?)
Ideally, if my dispatcher deems that the user does not have enough
privilidges (the page is @Secured(ROLE_ADMIN) for instance)  then all of
the action links on this page would also require this role to be invoked.

On pages where the the role required is less than admin, for example,
ROLE_USER, these pages could contain actions that are only for
administrators, so it would be nice to attach an annotation to the
onAction() methods where increased security is required.

If someone can shed some light on the best way of implementing this I would
appreciate it very much.  I don't want to write boilerplate code at the
start of every onAction() method that needs to be secured, and I don't want
to extend base classes or mess about with onActivate()  so ideally I would
like a solution that is similar to the dispatcher or some sort of filter.

Many Thanks,
Daniel
   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Protecting ActionLinks when using a Dispatcher.

2009-02-05 Thread Jonathan O'Connor

Thiago,
I thought about the service idea, but what would it look like?
Class extractPageClass(String requestPath) would be what I'd want.

However, for each Dispatcher, you'd want a PageClassExtracter as well, 
and I'm sure there'd be lots of duplication. To stay DRY, I guess we 
have to add the extractPageClass method to the Dispatcher interface, 
which is not very nice, especially as the AssetDispatcher does not use 
pages. Maybe we could extend Dispatcher to UsesPagesDispatcher that has 
our method. Now, we can iterate through the Dispatcher pipeline, and 
call extractPageClass only on the UsesPagesDispatchers.


Does that all make sense? Or is there a better way?
Ciao,
Jonathan

On 05/02/2009 18:59, Thiago H. de Paula Figueiredo wrote:
Em Thu, 05 Feb 2009 07:40:24 -0300, Jonathan O'Connor 
ninki...@eircom.net escreveu:



Daniel,
I was looking at this problem the other day, and you should look at 
the ComponentEventDispatcher. I think you need to first check if you 
get a matching page, and then check if you have an event. You can 
then extract the Pagename from the request path using that monster 
Reg exp. Sadly, this all relies on internal code :-(


I have the same need of extracting the page name from a Request. 
Should we file a JIRA to have a public service that does that?




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Protecting ActionLinks when using a Dispatcher.

2009-02-05 Thread Jonathan O'Connor

Thiago,
I guess you want the Class if your doing annotation based protection, 
and the string if you have some sort of map. But, as Daniel mentioned, 
you can get a ComponentSource, and convert the string to a Class, so no 
problems there.


The problem is deciding what a normally dispatched request is. 
Tapestry's whole philosophy is that my dispatcher/Service/Component is 
as normal as any other dispatcher/Service/Component. Just today I saw 
some messages about more RESTful URLs, that get converted to a page with 
parameters. Any dispatcher that converts the request to a Page/Component 
class will need to be involved in the complete solution.


Hmm, interesting design problem. It's after midnight here, so maybe I'll 
think some more tomorrow.

Ciao,
Jonathan
On 05/02/2009 20:51, Thiago H. de Paula Figueiredo wrote:
Em Thu, 05 Feb 2009 15:20:02 -0300, Jonathan O'Connor 
ninki...@eircom.net escreveu:



Thiago,


Hi!


I thought about the service idea, but what would it look like?
 Class extractPageClass(String requestPath) would be what I'd want.


That's what I want too. I would add a String extractPageName(String 
requestPath), returning the Tapestry page name (something like 
admin/user/edit).


However, for each Dispatcher, you'd want a PageClassExtracter as 
well, and I'm sure there'd be lots of duplication.


I haven't thought of the dispatcher issue yet, but maybe we could 
suppose that our new service would deal only with normally-dispatched 
requests.




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Protecting ActionLinks when using a Dispatcher.

2009-02-05 Thread Jonathan O'Connor

Howard,
this saves me any more cogitation for now!
Ciao,
Jonathan

On 05/02/2009 20:11, Howard Lewis Ship wrote:

The ComponentRequestHandler pipeline (new in 5.1) is for this purpose.
  You can contribute a ComponentRequestFilter; your filter is passed
all the details of the request (page names, nested ids, page
activation context, event context) and can decide how to proceed.

CRH pipeline is a facade around two different pipelines:
ComponentEventRequestHandler and PageRenderRequestHandler.  In some
cases, you may want to contribute a filter to once of those pipelines
instead.


On Thu, Feb 5, 2009 at 12:51 PM, Thiago H. de Paula Figueiredo
thiag...@gmail.com  wrote:
   

Em Thu, 05 Feb 2009 15:20:02 -0300, Jonathan O'Connorninki...@eircom.net
escreveu:

 

Thiago,
   

Hi!

 

I thought about the service idea, but what would it look like?
 Class extractPageClass(String requestPath) would be what I'd want.
   

That's what I want too. I would add a String extractPageName(String
requestPath), returning the Tapestry page name (something like
admin/user/edit).

 

However, for each Dispatcher, you'd want a PageClassExtracter as well, and
I'm sure there'd be lots of duplication.
   

I haven't thought of the dispatcher issue yet, but maybe we could suppose
that our new service would deal only with normally-dispatched requests.

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


 




   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [T5] filesystem asset problems

2009-02-05 Thread Jonathan O'Connor

Manuel,
look at the AssetDispatcher class. That will clear up a lot of problems, 
I think.

Ciao,
Jonathan

On 06/02/2009 00:49, manuel aldana wrote:

hi,

want to create a new asset-type, which makes images available from 
filesystem (file:/) to webapp (http:/), but somehow I don't get it...


I am sure at least some of my assumptions are wrong:
-with Asset framework I can make resources available through tapestry 
webapp context (http://xxx url is then kind of a gateway to the Resource)
-Resource is the real resource (file, other website, relative context 
path etc.)
-AssetFactory implementation tells how to map between the resource and 
the client-view (- toClientUrl())
-if everything works fine, the resource is loaded (amongst others 
AbstractResource.openStream() loads the contents) and is passed to the 
AssetFactory impl


My biggest doubt to my expectations is that for tapestry it should be 
very difficult to track the toClientUrl() return value to its own 
webcontext, e.g.: how should it know that 
http://domain:port/tapestryApp/toClientUrlValue points to 
file://d:/srv/images/? It then would need to handle a lot of URL 
redirecting magic internally.


Any other option for making my filesystem pics accessible to the same 
domain:host as the tapestry app is running without putting it to one 
of the jars or to webapp-context?


thanks a lot.



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Dynamic Assets

2009-02-04 Thread Jonathan O'Connor

Sid,
I think you will have to create a new binding prefix like myAsset:, 
and hook it in to a dispatcher that returns a StreamResponse. That way 
you can decide how to read the images, e.g. from DB, or from directory 
on your server. Your myAsset binding prefix will probably convert the 
value into a url like: /mySpecialAssets/someAsset


Do a search for adding a new binding prefix. And then look at the 
Dispatcher class. You will need to subclass it, and specify your own 
dispatch function. Something like this should be right (not tried at all 
in code)


public boolean dispatch(Request request, Response response) {
if (!request.getPath().startsWith(/mySpecialAssets/) {
return false;
}
OutputStream os = response.getOutputStream(image/png);
os.write(loadMySpecialAsset(request.getPath()));
os.flush();
return true;
}

Sorry for the very rough ideas, I'm only getting started with T5 too.

Good luck,
Jonathan

On 04/02/2009 13:18, Sid Ferreira wrote:

example in a _dynamic_ folder shared between some projects.

On Wed, Feb 4, 2009 at 11:17, Sid Ferreirasid@gmail.com  wrote:

   

No they are outside the webapp, I mean a custom asset wich is anywhere in
my server. For example in a folder shared between some projects.


On Wed, Feb 4, 2009 at 11:15, Thiago H. de Paula Figueiredo
thiag...@gmail.com  wrote:

 

On Wed, Feb 4, 2009 at 10:58 AM, Sid Ferreirasid@gmail.com  wrote:
   

This part of prefix and symbols I know, I wanted to mean about custom
assets,
 

Where are the assests? Are they inside the webapp context? If yes,
then Tapestry already does what you need.
What do you mean about custom assets?

--
Thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


   

--
Sidney G B Ferreira
Desenvolvedor Web - Tibox Innovations


 



   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: Component Suggestion/Question

2009-01-22 Thread Jonathan O'Connor

James,
I just did this yesterday. Its based on the code found in the WIKI: 
http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained


My Javascript code sets the class of an element to vanished that does 
display:none in my stylesheet.


// A class that hides and shows the simple and complex input elements of 
the form.

var CustomerSearchInputToggler = Class.create();
CustomerSearchInputToggler.prototype = {
initialize: function(element, makeSimple) {
if (makeSimple) {
Event.observe($(element), 'click', 
this.simplify.bindAsEventListener(this));

} else {
Event.observe($(element), 'click', 
this.complicate.bindAsEventListener(this));

}
},

hide: function(element) {
$(element).className = 'vanished';
},

show: function(element) {
$(element).className = '';
},

simplify: function(e) {
this.hide('complex');
this.hide('complex1');
this.hide('complex2');
this.show('simple');
this.show('simple1');
return true;
},

complicate: function(e) {
this.show('complex');
this.show('complex1');
this.show('complex2');
this.hide('simple');
this.hide('simple1');
return true;
}
}

Tapestry.onDOMLoaded(function() {
new CustomerSearchInputToggler('complex', true);
new CustomerSearchInputToggler('simple', false);
CustomerSearchInputToggler.prototype.simplify(null);
});

complex and simple are 2 links in the tml file, simpleX and complexX are 
paragraphs, but they could be any element that you want hidden or shown:

a id=complex href=#${message:makeSimple}/a
a id=simple href=#${message:makeComplex}/a

You also need to inject the javascript file:
@IncludeJavaScriptLibrary(CustomerSearch.js)

This solution is not perfect, because on load hides the complex input 
fields only after they have been displayed, so the screen flashes. Now I 
could add default styles of display:none to the complexX elements, but 
if the user has Javascript turned off, then they can never see the 
complex parts of the screen. I suppose I could make the anchor links 
ActionLinks, so that when Javascript is not running, the user goes back 
to the server, which refreshes the page showing the complex parts.


What I do like about Tapestry's way of handling Javascript is, one never 
sees onclick attributes in the HTML.


Hope this helps,
Jonathan

On 22/01/2009 02:10, Thiago H. de Paula Figueiredo wrote:
Em Wed, 21 Jan 2009 22:01:43 -0300, James Sherwood 
jsherw...@rgisolutions.com escreveu:



You are like our own little tapestry tutor, and its MUCH appreciated:)


I'm just a guy who wants to bring sanity and pleasure and elegance 
(Tapestry 5!) to the Java Web development world . . . :) And a guy 
with a little too much free time in his hands, as I'm currenty working 
part-time in a project with a local company and the rest of the time 
in my own projects. All them implemented in Tapestry and the Ars 
Machina Project packages (www.arsmachina.com.br/project) . . .


Before I go looking into the code, would it be possible to build one 
whereby

you just click an image to change hidden/shown of the form fragment?


I think so: it would be a matter of writing/generating Javascript code 
handling the click event of an image/link/whatever and showing/hiding 
the form fragment. It shouldn't be hard.


If so would I just start by basing it off the built in checkbox 
component?


I think you will find the answers you want in the TriggerFragment 
component 
(http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/mixins/TriggerFragment.html). 
Look at the Javascript it adds to the page and try to imitate it in 
your component.


Unfortunately the checkbox is such an ugly/clunky implementation of a 
really awesome little component.


I agree . . .



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Adding onclick to row in Grid component

2009-01-21 Thread Jonathan O'Connor

Hi,
I have a grid, and I want the user to be able to click on a row to 
select it.
I know I can add a link to each cell, but that's not very nice, as the 
link only works if you click on text, and there could be plenty of 
whitespace in the row.


I see there is a GridRows component, which is part of each Grid, but the 
documentation on the GridRows component has no example. From memory of 
Tap3, I seem to remember building up a table using underlying 
components. Do I need to that here too?


Thanks,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Where to check that the user is logged in when rendering a page

2009-01-16 Thread Jonathan O'Connor

Hi,
I have been reading the documentation, and I haven't seen what I need to 
find out: How can a page finding that the user is not logged in, it 
should jump to a login page, and optionally jump back to the requested page?


I already know how to check the session to see if a) there is a session, 
and b) that a user logged in correctly. What I need to know is:
1. What method/annotation do I need to write in my page class before the 
page renders
2. Presumably, I want to return a Page or a URL from this method, to 
redirect to the login page.
3. Should the login page take a hidden field to say which page it wants 
to go to next?


BTW, I would love to see, in one place, a list of all the methods added 
by the classloader, how it was triggered. The list I know about are:
1. Component Rendering Methods: setupRender, beginRender, 
beforeRenderTemplate, beforeRenderBody, afterRenderBody, 
afterRenderTemplate, afterRender, cleanupRender.

2. Page Lifecycle methods: pageLoaded, pageAttached, pageDetached
3. Page activation events: onActivate, onPassivate
4. Action events: onActionFromBlah, onSubmit
5. Form events: prepareForRender, prepare, prepareForSubmit, onValidate, 
onSuccess, onFailure, onSubmit

6. getters and setters of @Property annotated private attributes.

No doubt I've missed a few more.
Thanks,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Where to check that the user is logged in when rendering a page

2009-01-16 Thread Jonathan O'Connor

Thiago,
thanks very much. That's basically what I did, and it works, but I don't 
like:

a) not having a passivate method (I have no need of one yet) and
b) I feel (due to the examples in the documentation) that activate 
should take a parameter as the id of some object I want to resurrect.


No doubt, I'll get used to it.
Ciao,
Jonathan

On 16/01/2009 15:55, Thiago HP wrote:

On Fri, Jan 16, 2009 at 1:42 PM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Hi,
 


Hi!

   

I have been reading the documentation, and I haven't seen what I need to
find out: How can a page finding that the user is not logged in, it should
jump to a login page, and optionally jump back to the requested page?
 


Use onActivate. One way to do it:

@InjectPage
private LoginPage loginPage;

Object onActivate() {
 if (user is not logged in) {
 // you could set any properties in the login page here.
 return loginPage;
 }
 else {
 return null; // continue rendering this page normally.
 }
}

On the other hand, if you need this behaviour to be applied to more
than one page, a RequestFilter would be the best way, as this would
put all the code in a single place and the pages wouldn't need to
bother with this issues. In this mailing list you can find some
examples, maybe in the wiki too. ;)

   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



T5: Pages can't have getErrorMessage() method

2009-01-13 Thread Jonathan O'Connor

Hi,
I have a page class that had a String getErrorMessage() method. Sadly, 
this is not allowed by Tap5, and I get a lovely exception page telling 
exactly what is going on.


Is this documented anywhere? I did a google for Tap5 and 
getErrorMessage, but didn't see anything relevant. My work around is to 
rename my method of course, but is this behavior correct?


1. If this is correct, then how do I set the error message that comes 
back from getErrorMessage?

2. Can I only invoke it from my tml file? e.g. ${errorMessage}
3. Is there a list of other methods that should not be specified in a 
page class, as they are added by the Tapestry class loader?


thanks,
Jonathan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: How to inject a Link

2009-01-05 Thread Jonathan O'Connor

Folks,
for posterity, I solved the problem using the request header fields.
1. the host header field is always guaranteed (according to the HTTP 
spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23) to 
exist.
2. The referer header field is always there because I'm handling a form 
submit request from my Tap5 Login page, and therefore, the referer is my 
login page.
3. I inject the RequestGlobals into my page class to get access to the 
HttpServletRequest object. I could have used an injected Request object 
to get the header fields and context path, but my page also needed the 
underlying HttpSession and ServletContext objects.


Because I'm paranoid, I wrote the following code
HttpServletRequest req = 
_requestGlobals.getHTTPServletRequest();

String referer = req.getHeader( referer );
String host = req.getHeader( host );
String contextPath = req.getContextPath();
String page = ;
if (referer != null  contextPath != null  
referer.contains( contextPath )) {
page = referer.substring( 0, referer.indexOf( 
contextPath ) ) + contextPath + /customerSearch.jsp;

} else if (referer == null) {
page = http://; + host + contextPath + 
/customerSearch.jsp;

}
_logger.info( Jumping to:  + page );
return new URL(page);

Hope this helps anyone in the same boat as I was,
Jonathan

On 03/01/2009 20:22, Howard Lewis Ship wrote:

You can return a URL no problem.  The trick is to generate a proper
URL even when behind a firewall.

On Fri, Jan 2, 2009 at 9:51 AM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Hi,
it must be too much Christmas cheer, but I am not sure how to jump to a
non-Tapestry URL in the same web app.

A little background: We have an old application written in Struts 1.1. I
have written my own Login page, called the old code to the user validation
and updating of the session.
This all works ala Kent Tong's eBook on Tap4. Now I want to jump to main
struts page of my app.

My onSuccess() method needs to return a Link or a URL, but according to the
docs, the URL should be used for completely external addresses (e.g.
google.com).

Can I inject a Link (LinkImpl is in the internal package, and so unusable)?
Or should I generate a relative URL?

Thanks and Happy New Year to one and all,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


 




   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: How to inject a Link

2009-01-03 Thread Jonathan O'Connor

Howard,
I tried the following:
HttpServletRequest req = getRequest();
String page = http://; + req.getLocalAddr() + :8080/ + 
req.getContextPath() + /myStrutsPage.jsp;

return new URL(page);

But, that returned http://127.0.0.1:8080/myApp/myStrutsPage.jsp instead 
of http://localhost:8080/myApp/myStrutsPage.jsp and that caused my 
struts app to think my session had timed out. I was hoping that if I 
created a proper Link, Tapestry would generate the proper URL for me :-)

I'll go hunting,
Ciao,
Jonathan

On 03/01/2009 20:22, Howard Lewis Ship wrote:

You can return a URL no problem.  The trick is to generate a proper
URL even when behind a firewall.

On Fri, Jan 2, 2009 at 9:51 AM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Hi,
it must be too much Christmas cheer, but I am not sure how to jump to a
non-Tapestry URL in the same web app.

A little background: We have an old application written in Struts 1.1. I
have written my own Login page, called the old code to the user validation
and updating of the session.
This all works ala Kent Tong's eBook on Tap4. Now I want to jump to main
struts page of my app.

My onSuccess() method needs to return a Link or a URL, but according to the
docs, the URL should be used for completely external addresses (e.g.
google.com).

Can I inject a Link (LinkImpl is in the internal package, and so unusable)?
Or should I generate a relative URL?

Thanks and Happy New Year to one and all,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


 




   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: How to inject a Link

2009-01-03 Thread Jonathan O'Connor

Howard,
yes, as I suspected, when I return a URL with http://localhost:8080 etc, 
the jump to the struts page works. Unfortunately, the HttpServletRequest 
object doesn't know the port (it thinks it's -1), and the localAddr is 
the ip address as a number, not a symbolic address, and the remote 
address is null :-(


I'll let you off the hook now!
Ciao,
Jonathan

On 03/01/2009 21:12, Jonathan O'Connor wrote:

Howard,
I tried the following:
HttpServletRequest req = getRequest();
String page = http://; + req.getLocalAddr() + :8080/ + 
req.getContextPath() + /myStrutsPage.jsp;

return new URL(page);

But, that returned http://127.0.0.1:8080/myApp/myStrutsPage.jsp 
instead of http://localhost:8080/myApp/myStrutsPage.jsp and that 
caused my struts app to think my session had timed out. I was hoping 
that if I created a proper Link, Tapestry would generate the proper 
URL for me :-)

I'll go hunting,
Ciao,
Jonathan

On 03/01/2009 20:22, Howard Lewis Ship wrote:

You can return a URL no problem.  The trick is to generate a proper
URL even when behind a firewall.

On Fri, Jan 2, 2009 at 9:51 AM, Jonathan 
O'Connorninki...@eircom.net  wrote:

Hi,
it must be too much Christmas cheer, but I am not sure how to jump to a
non-Tapestry URL in the same web app.

A little background: We have an old application written in Struts 
1.1. I
have written my own Login page, called the old code to the user 
validation

and updating of the session.
This all works ala Kent Tong's eBook on Tap4. Now I want to jump to 
main

struts page of my app.

My onSuccess() method needs to return a Link or a URL, but according 
to the

docs, the URL should be used for completely external addresses (e.g.
google.com).

Can I inject a Link (LinkImpl is in the internal package, and so 
unusable)?

Or should I generate a relative URL?

Thanks and Happy New Year to one and all,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org








-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5 newbie books/tutorials and a couple of questions?

2009-01-03 Thread Jonathan O'Connor

Kevin,
I'm a believer in Samson and Delilah. Cutting your hair is making you 
weak! As a chess player, I never play chess the week after I get a 
haircut, as I just loose. Also, Garry Kasparov, former world champion, 
used to say that the brain worked better if it was 1 degree warmer than 
the rest of the body. So if you must shave your head, at least wear a 
woolly hat. Thinking caps are also good!

Ciao,
Jonathan

On 03/01/2009 05:57, Kevin Monceaux wrote:

Jonathan,

On Fri, 2 Jan 2009, Jonathan Barker wrote:

Search the list for the Jumpstart application.  It has been kept 
right up to date with the latest release of T5.  I think you will 
find it has many good examples. (Also, search the Wiki for titles 
with Tapestry5. It's not all up to date, but there's some great 
stuff.)


It looks like there's plenty there to keep me busy for a while.  It 
doesn't seem to have any ManyToMany relation examples.  The following 
in the Jumpstart root directory:


# find . -name *.java -exec grep ManyToMany {} \;

returns nothing.  But, it does have a few OneToMany relations, which 
should be close enough to get me started.


Searching the wiki for ManyToMany also turned up next to nothing.  It 
turned up a couple of pages, but they just mentioned OneToMany, 
ManyToMany, etc., in passing without any actual code examples of the 
annotations.  I was sure I saw a few examples in the tapestry5 doc 
section.  Is the main Tapestry site indexed by Google?  A Google 
search for:


site:tapestry.apache.org/tapestry5 ManyToMany

got no hits at all.

I'm not sure you really want a grid for what you have displayed, but 
rather
Loops generating the tables on your own.  Because you have both 
column and
row groupings (COLSPAN,ROWSPAN) on the pages you listed, I'm not sure 
how

you would do things like apply sorting.


I suspected that might be the case.  The grid component is impressive 
enough as it is.  If it could magically handle multi-level 
hierarchical data I might not know how to act.  :-)  With Django I'm 
currently generating those pages with nested loops.  Before Django I 
gave ASP.NET(via Mono on a FreeBSD box) a try and was generating those 
pages by dumping the data to XML and using XSLT.


Hibernate has a learning curve all its own, so if you're not familiar 
with it, take some time to learn it on its own.  At least be prepared 
for some hair-pulling if you try to learn both Tapestry and Hibernate 
at the same time.


I'm a relative newbie to Tapestry, Hibernate, and Java.  It might be a 
good thing that I have very little hair.  I figure if I'm going to go 
bald some day I might as well beat nature to it.  I alternate between 
clipping it as short as clippers will clip it, and shaving my head.  
I've let it grow out a bit for winter.  Maybe I should shave it before 
Hibernate drives me to trying to pull what little I have left out.  :-)




Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

Si hoc legere scis nimium eruditionis habes.
Longum iter est per praecepta, breve et efficax per exempla!!!


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



T5: How to inject a Link

2009-01-02 Thread Jonathan O'Connor

Hi,
it must be too much Christmas cheer, but I am not sure how to jump to a 
non-Tapestry URL in the same web app.


A little background: We have an old application written in Struts 1.1. I 
have written my own Login page, called the old code to the user 
validation and updating of the session.
This all works ala Kent Tong's eBook on Tap4. Now I want to jump to main 
struts page of my app.


My onSuccess() method needs to return a Link or a URL, but according to 
the docs, the URL should be used for completely external addresses (e.g. 
google.com).


Can I inject a Link (LinkImpl is in the internal package, and so unusable)?
Or should I generate a relative URL?

Thanks and Happy New Year to one and all,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



T5: Proper project layout?

2008-12-18 Thread Jonathan O'Connor

Hi,
I've just started working with Tapestry 5, and I have found 2 different 
project layouts. Howard (I presume) suggested the one found in the 
guide: http://tapestry.apache.org/tapestry5/guide/project-layout.html 
and Geoff Callender has a different one in his jumpstart project. The 
main difference is that Geoff keeps the tml files in the same directory 
as the java classes. I prefer this as I don't need to jump about in the 
directory structure finding the matching Java or tml file. However, the 
guide explicitly says:
Component templates will always be stored in the resources folder. Is 
this documentation up to date?


Thanks,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: Proper project layout?

2008-12-18 Thread Jonathan O'Connor

Andy,
thanks. I just joined up last night!
Ciao,
Jonathan

On 18/12/2008 13:37, Andy Pahne wrote:



This has been discussed a few days ago. Search for the thread 
Advantages of various .tml storage locations?


Andy



Jonathan O'Connor schrieb:

Hi,
I've just started working with Tapestry 5, and I have found 2 
different project layouts. Howard (I presume) suggested the one found 
in the guide: 
http://tapestry.apache.org/tapestry5/guide/project-layout.html and 
Geoff Callender has a different one in his jumpstart project. The 
main difference is that Geoff keeps the tml files in the same 
directory as the java classes. I prefer this as I don't need to jump 
about in the directory structure finding the matching Java or tml 
file. However, the guide explicitly says:
Component templates will always be stored in the resources folder. 
Is this documentation up to date?


Thanks,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: Proper project layout?

2008-12-18 Thread Jonathan O'Connor

Jonathan,
yes, I used to be a big fan of spindle when I worked in Tap3, many moons 
ago!

I'll grab it now.
Ciao,
Jonathan

On 18/12/2008 15:15, Jonathan Barker wrote:

The Loom plugin for Eclipse (see link on the T5 main page) makes that
jumping around painless.


   

-Original Message-
From: Jonathan O'Connor [mailto:ninki...@eircom.net]
Sent: Thursday, December 18, 2008 08:16
To: users@tapestry.apache.org
Subject: T5: Proper project layout?

Hi,
I've just started working with Tapestry 5, and I have found 2 different
project layouts. Howard (I presume) suggested the one found in the
guide: http://tapestry.apache.org/tapestry5/guide/project-layout.html
and Geoff Callender has a different one in his jumpstart project. The
main difference is that Geoff keeps the tml files in the same directory
as the java classes. I prefer this as I don't need to jump about in the
directory structure finding the matching Java or tml file. However, the
guide explicitly says:
Component templates will always be stored in the resources folder. Is
this documentation up to date?

Thanks,
Jonathan O'Connor

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
 



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



   


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: Proper project layout?

2008-12-18 Thread Jonathan O'Connor

Luther,
that's brilliant. Just the info I needed. For my sins, I have to 
integrate Tap5 with an existing struts 1.1 app :-(
I have no desire to go anywhere near maven, especially as the existing 
project uses ant.


I would like to keep all .tml files in src/main/resources. But this will 
depend on where my images and stylesheets go.

I haven't figured that out yet.

Now I would really like a page in the Tap5 guide titled WAR Layout.
Ciao,
Jonathan

On 18/12/2008 16:09, Luther Baker wrote:

For what it is worth, the directory structure you are referring to is really
dictated by Maven and not Tapestry per-se.

Normally, Maven build commands do not copy non-Java files from
'src/main/java' into the resulting archive. Per Maven convention, non-Java
files that should end up in the classpath should be in 'src/main/resources'.

But for example, Eclipse was not built around nor does it have to adhere to
Maven standards. As far as Tapestry is concerned, as long as the end result
is the same (Java and *.tml files have to be collocated in the classpath or
tml files belong in the web root) everything will work just fine.
Consequently, out of error, convenience or blatant disregard :-) different
developers place these SRC files in different places and configure their IDE
to create a proper end result - but per Maven conventions, to include text
(or non-Java) files in a resulting archive classpath, they should be kept in
the 'src/main/resources' path.

There is one additional point here. As I've alluded to, Tapestry is built to
look in TWO places for *.tml files. a) the classpath and b) the web root.
Remember, this is the RESULTING location. If you are using a Maven build
process, these equate to a) 'src/main/resources' and b) 'src/main/webapp'.

Much of the conversation in recent posts was around the best place to place
the *.tml files - ie: in the classpath or in the web application root. To
clarify, the jumpstart example you mention below is actually using the
CLASSPATH option but it is doing so contrary to Maven conventions. Remember
Tapestry cares only about the RESULTING location ... you are actually asking
about the SRC location. So again, if you like the approach that the
jumpstart example uses, and you alter your Maven build to include text files
from the java directory, you are fine ...

Small project with no one else on it? Do what you like and just make sure
the final build is conistent with what Tapestry requires. Larger project,
developers added and removed, long running? You may want to adhere more
tightly to a stricter, conventional Maven structure (orthogonal to Tapestry)
and keep your *.tml files in the webapp root or the resources directory.

If you have an automated build engine ... or continuous integration and you
want to run something like 'mvn install' from the command line over your
code ... convention would dictate that your *.tml files exist either in
'src/main/resources' (claspath) or 'src/main/webapp' (web application root).
Putting text files in the 'src/main/java' directory is a
play-at-your-own-risk move - very doable - but not per Maven conventions
 That said, you can customize your Maven pom.xml file --- but again,
that is generally frowned upon - especially when it comes to redefining
directories and files kept in custom paths. It adds complexity - you just
have to decide if it works for your org.

Hope that helps - sorry for the long-windedness. I'm a big fan of Maven -
and convention over configuration ... but if you get confused separating
your *.tml files the corresponding *.java files - by all means - optimize
your workflow. Just be aware of the tradeoffs you are making with such
customizations. Remember to distinguish the SRC locations from the RESULTING
locations in the archive. Tapestry doesn't care about the SRC location. You
can put your *.tml files in /home/tmp if you like. It is the resulting
ARCHIVE or Eclipse IDE that has to include them in either a) the classpath
or b) the webroot.

-Luther


On Thu, Dec 18, 2008 at 9:34 AM, Jonathan O'Connorninki...@eircom.netwrote:

   

Jonathan,
yes, I used to be a big fan of spindle when I worked in Tap3, many moons
ago!
I'll grab it now.
Ciao,
Jonathan


On 18/12/2008 15:15, Jonathan Barker wrote:

 

The Loom plugin for Eclipse (see link on the T5 main page) makes that
jumping around painless.




   

-Original Message-
From: Jonathan O'Connor [mailto:ninki...@eircom.net]
Sent: Thursday, December 18, 2008 08:16
To: users@tapestry.apache.org
Subject: T5: Proper project layout?

Hi,
I've just started working with Tapestry 5, and I have found 2 different
project layouts. Howard (I presume) suggested the one found in the
guide: http://tapestry.apache.org/tapestry5/guide/project-layout.html
and Geoff Callender has a different one in his jumpstart project. The
main difference is that Geoff keeps the tml files in the same directory
as the java classes. I prefer this as I don't need to jump about in the
directory

Re: Tapestry 3 and Valid XHTML Forms (generated Script tag)

2007-05-30 Thread Jonathan O'Connor
Andrew,
sorry I can't help you on that. I guess get out and grep for script. Try
putting a breakpoint on the rendering methods, and see what happens.
Ciao,
Jonathan O'Connor
XCOM Dublin


   
 Andrew Ingram 
 [EMAIL PROTECTED] 
 tanemail.com  To 
   Tapestry users  
 30.05.2007 13:58  users@tapestry.apache.org 
cc 
   
 Please respond to Subject 
 Tapestry users  Re: Tapestry 3 and Valid XHTML  
 [EMAIL PROTECTED] Forms (generated Script tag)
pache.org 
   
   
   
   
   




Thanks Jonathan,

I'm down to just one tapestry-generated validation error now.

I'm still getting the language attribute on script tags (example below),
i've looked through the tapestry source and the scripting stuff seems a
bit complicated, even if I tell the component to not use client side
scripting it still generates a small amount of script (used for focusing
the text input).

I'm interested in knowing two things:
1) Where in tapestry is the script tag written and how can I overwrite
it to not use the language attribute?
2) Can I make a validfield generate no javascript whatsoever?

Example output:

script language=JavaScript type=text/javascript
src=/app?service=assetamp;sp=S%2Forg%2Fapache%2Ftapestry%2Fvalid%2FValidator.jsamp;sp=S3dfc7ba91240b3bbd49fbb3efe31/script

script language=JavaScript type=text/javascript!--


function
validate_SearchField()
{
  var field = document.Form0.SearchField;

  if
(field.value.length == 0)
 return validator_invalid_field(field, You
must enter a value for the search to work...);


  if (field.value.length 
1)
 return validator_invalid_field(field, You must enter at least 1
characters for the search to work...);

  return true;
}


window.onload =
function ()
{
document.Form0.SearchField.focus();
document.Form0.SearchField.select();
document.Form0.onsubmit =
validate_SearchField;
}


Regards,
Andrew Ingram



Jonathan O'Connor wrote:


Andrew,
 you will have to roll your own components. The ImageSubmit
component 
 should be fairly easy. Just copy the source for the ImageSubmit
 component, and then alter the code to avoid outputing a border 

attribute. You can probably also extend from ImageSubmit, and change 
 the
rendering.

 You should be able to do the same with the Form class too.


Sorry I can't be more explicit, but its over a year since I did any 

Tapestry work (all Tap3).
 Good luck,
 Jonathan O'Connor
 XCOM Dublin

__
This
email has been scanned by the MessageLabs Email Security System.
For more
information please visit http://www.messagelabs.com/email
__
-
To
unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
commands, e-mail: [EMAIL PROTECTED]




*** XCOM AG Legal Disclaimer ***

Diese E-Mail einschliesslich ihrer Anhaenge ist vertraulich und ist allein
für den Gebrauch durch den vorgesehenen Empfaenger bestimmt. Dritten ist
das Lesen, Verteilen oder Weiterleiten dieser E-Mail untersagt. Wir bitten,
eine fehlgeleitete E-Mail unverzueglich vollstaendig zu loeschen und uns
eine Nachricht zukommen zu lassen.

This email may contain material that is confidential and for the sole use
of the intended recipient. Any review, distribution by others or forwarding
without express permission is strictly prohibited. If you are not the
intended recipient, please contact the sender and delete all copies.

Hauptsitz: Bahnstrasse 37, D-47877 Willich, USt-IdNr.: DE 812 885 664
Kommunikation: Telefon +49 2154 9209-70, Telefax +49 2154 9209-900,
www.xcom.de
Handelsregister: Amtsgericht Krefeld, HRB 10340
Vorstand: Matthias Albrecht, Renate Becker-Grope, Marco Marty, Dr. Rainer
Fuchs
Vorsitzender des Aufsichtsrates: Stephan Steuer