On Tue, 16 Aug 2011 21:06:05 -0300, ixcoatl <ixcoatl_pe...@yahoo.com.mx> wrote:

Hi,

Hi!

I'm having some trouble shifting from the conventional event-driven model to the way Tapestry works.

Tapestry is event-driven too, but

Is there a newbie forum where I can ask the most basic questions?

This is the place for asking all questions about Tapestry, from the most basic to the more complex ones. :)

Right now I'm stuck trying to jump from one page in charge to create users to others in charge of editing and deleting them.

I guess you're using a structure that isn't common. The common pattern I see for CRUDs is to have one page for listing/searching and one for editing (both existing and new objects). Removing is generally implemented as an event in the listing page, but in the edition page too.

This is the code of the list with the already created users is:

        <t:grid source="usuarios" add="editar,borrar" rowsPerPage="5"
include="nombre,controlarUsuarios,crearProyectos">
            <p:editarcell>
                <t:actionlink t:id="editarUsuario"
page="seguridad/editarUsuario" context="nombre" >Editar</t:actionlink>

Common newbie error: in Tapestry, events are always triggered and handled inside a given page. In other words, one page doesn't trigger an event in another page. In this case, you have an edition page for Usuario, so you should use a PageLink instead of ActionLink.

            </p:editarcell>
            <p:borrarcell>
                <t:actionlink t:id="borrarUsuario"
page="seguridad/BorrarUsuario" context="nombre" >Borrar</t:actionlink>
            </p:borrarcell>

ActionLink doesn't have a page parameter, so it's ignored. As Robert said, to handle this event, you should write an onActionFromBorrarUsuario(String nombre) to handle this event. You can also use any method name and annotate it with @OnEvent(value = "event name", component = "t:id of the component).

            <p:empty>
              <p>No hay informacion en la lista.</p>
            </p:empty>
        </t:grid>

Both seguridad/BorrarUsuario and seguridad/editarUsuario are pages intended to handle the delete and edit tasks

Why do you need a page for removing users? Isn't an event enough?

(sorry the code is in spanish).

I'm Brazilian, my first language is Portuguese, I don't speak Spanish and I could understand your code without problems. :)

However
the jump never happens and the methods onActionFromBorrarUsuario and
onActionFromEditarUsuario are being called on the page where the grid
exists.

The jump doesn't happen because ActionLink (and also EventLink) only trigger events in the page they were declared.

Then I thought that returning a BorrarUsuario page from this methods should be enough, for that I put:

    @InjectPage("seguridad/BorrarUsuario")
    private EditarUsuario eu;

You don't need to specify the page name in 99% of the cases. Just the type of the field is enough.

or

    @Inject
    private EditarUsuario eu;

@InjectPage and @Inject are very different. @Inject inject a service configured thought Tapestry-IoC. @InjectPage is the way of getting a page instance in Tapestry.

   No service implements the interface
compucentro.volumetria.pages.seguridad.EditarUsuario.

The message is quite descriptive: you haven't declared a Tapestry-IoC service of type EditarUsuario. You should have used just @InjectPage private EditarUsuario eu;

It would be very nice to have a tutorial on how to implement a full
create/update/delete cycle using hibernate, that way a newbie can get the
feeling of how manage the set of objects (pages, entities, etc. ) involved with DB access.

Have you checked the Hotel Booking example application (http://tapestry.zones.apache.org:8180/tapestry5-hotel-booking/signin, source code linked in the bottom of the page) or Tapestry JumpStart (http://jumpstart.doublenegative.com.au/) or the Tapestry-Hibernate documentation (http://tapestry.apache.org/hibernate.html)?

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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

Reply via email to