You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mindaugas Genutis <mi...@elinara.ktu.lt> on 2003/08/22 16:43:38 UTC

Add a Form to the ITableColumnModel

Hello,

I'm using contrib:Table with ITableColumnModel to display application 
data. I need to add action buttons on each record ("Edit", "Delete"). This 
means I must put HTML forms inside the last Table column.

Is it possible to give a form object to the ITableColumnModel? Will Table 
print it? If so, how to do it?

Maybe this approach isn't very clean. Is there another way of doing this?

Thanks,

-- 
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


Re: Add a Form to the ITableColumnModel

Posted by "F. Da Costa Gomez" <dc...@fixed.com>.
Mindaugas Genutis wrote:

>Hello,
>
>I'm using contrib:Table with ITableColumnModel to display application 
>data. I need to add action buttons on each record ("Edit", "Delete"). This 
>means I must put HTML forms inside the last Table column.
>  
>
You could put it *around* the tabel instead & then 'catch' the action 
button.
The button could be a 'css button' so that you can make a Direct- or 
ActionLink that gives you all you need to know about the row y'r working on.
Assuming you want to work on a row basis.

I believe there is an example of this in LocaleList or LocaleSelection 
(MB will prob correct me if I'm wrong ;-) )

You can also use the checkbox instead of delete.
Process the whole form (= part of the table shown) and do 1 submit 
button for the whole lot.

The same would go for the edit button. Depending on what you want to do 
you could make the fields in the table editable and process the lot on 
submission.

>Is it possible to give a form object to the ITableColumnModel? Will Table 
>print it? If so, how to do it?
>
>Maybe this approach isn't very clean. Is there another way of doing this?
>
>Thanks,
>
>  
>




RE: Help needed: DirectLink in a table

Posted by Mindaugas Genutis <mi...@elinara.ktu.lt>.
Thanks for pointing this out for me. My colleague showed this to me just 
a few minutes ago. Look what we found in the ServiceLink component doc:

context: Deprecated name for parameters. This will emit warnings in 2.2 
and be removed in a later release entirely. 

Thus, the 'context' I was using was already deprecated.

The ServiceLink component 

> I think there is tiny error in the definition of the DirectLink component:
> 
>         <binding name="context" expression='user'/>
> 
> should be
> 
>         <binding name="parameters" expression='editDirectContext'/>
> 
> As described in the Component Reference, this should invoke the method
> getEditDirectContext() to obtain the parameters of the DirectLink. Those
> parameters are then used by the editDirectListener() method. At the moment
> there are none, since the 'parameters' binding is not set, and hence you get
> a null pointer exception.
> 
> 
> Btw, just to let you know -- there is an additional example of exactly what
> you need in the LocaleSelection component in the Workbench that achieves the
> same result in a slightly different way. What was suggested, however, could
> be simpler in many circumstances, so see if you can get it to work first.
> 
> Best regards,
> -mb
> 
> 
> -----Original Message-----
> From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> Sent: Monday, August 25, 2003 4:17 PM
> To: tsvetelin
> Cc: Tapestry users
> Subject: RE: Help needed: DirectLink in a table
> 
> 
> 
> Hello again,
> 
> I've updated the code according to all your comments today. Unfortunately,
> I still get the same error:
> 
> Unable to invoke method editDirectListener on
> lt.ktu.distance.elearn.pages.UsersPage@7fcd7e[Users]: null
> 
> The user in the actual edit method is still null. I'll paste all the
> relevant code again, maybe someone can spot the mistake:
> 
> Maybe someone has all the files for such an example?
> 
> +-----------------------------------------------------+
> The page specification:
> 
> <page-specification class="lt.ktu.distance.elearn.pages.UsersPage">
>     <component id="tableView" type="contrib:TableView">
>        <binding name="tableModel" expression="tableModel"/>
>     </component>
> 
>     <component id="tableColumns" type="contrib:TableColumns">
>     </component>
> 
>     <component id="tableRows" type="contrib:TableRows">
>         <binding name="row" expression='user'/>
>     </component>
> 
>     <component id="tableValues" type="contrib:TableValues">
>     </component>
> 
>     <component id="editDirectLink" type="DirectLink">
>         <binding name="context" expression='user'/>
>         <binding name="listener"
> expression='listeners.editDirectListener'/>
>     </component>
> </page-specification>
> +-----------------------------------------------------+
> 
> +-----------------------------------------------------+
> The Users.html file:
>   <table jwcid="tableView" border="1" cellpadding="2" cellspacing="1">
>     <tr>
>         <span jwcid="tableColumns" />
>         <th><p class="normal_text">Action</p></th>
>     </tr>
>     <tr jwcid="tableRows">
>       <td jwcid="tableValues"/>
>       <td >
>         <a jwcid="editDirectLink">Edit</a>
>       </td>
>     </tr>
>   </table>
> +-----------------------------------------------------+
> 
> +-----------------------------------------------------+
> The UsersPage.java:
> public class UsersPage extends BasePage
> {
>     public ITableModel getTableModel()
>     {
>         ManagerFactory managerFactory = new ManagerFactory();
>         UserManager userManager = managerFactory.createUserManager();
> 
>         Iterator users = userManager.loadUsers();
> 
>         ITableColumnModel objColumnModel =
>                 new ExpressionTableColumnModel(new String[]{
>                     "Login", "login",
>                     "Type", "type",
>                     "First Name", "firstName",
>                     "Last Name", "lastName",
>                     "Email", "email",
>                     "Phone", "phone",
>                     "Address", "address",
>                     "Occupation", "occupation",
>                     "Organisation", "organisation"
>                 }, true);
> 
>         ArrayList userArrayList = new ArrayList();
> 
>         while (users.hasNext())
>         {
>             User user = (User) users.next();
>             userArrayList.add(user);
>         }
> 
>         return new SimpleTableModel(userArrayList.toArray(),
> objColumnModel);
>     }
> 
>     private User mUser = null;
> 
>     public User getUser()
>     {
>         return mUser;
>     }
> 
>     public void setUser(User user)
>     {
>         mUser = user;
>     }
> 
>     public Object[] getEditDirectContext()
>     {
>         return new Object[]{getUser().getId()};
>     }
> 
>     public void editDirectListener(IRequestCycle cycle)
>     {
>         Object[] arrDirectParams = cycle.getServiceParameters();
>         Object objObjectUID = (Integer)arrDirectParams[0]; // Null exception
> is thrown here
>     }
> }
> +-----------------------------------------------------+
> 
> Thanks,
> 
> > Sorry but I have made a small error in my example. In the definition of
> > TableRows component the parameter "context" should be "row":
> >     <component id="tableRows" type="contrib:TableRows">
> >         <binding name="row" expression='user'/>
> >     </component>
> >
> > And the parameter "row" of DirectLink should be "context"
> >     <component id="editDirectLink" type="DirectLink">
> >         <binding name="context" expression='user'/>
> >         <binding name="listener"
> > expression='listeners.editDirectListener'/>
> >     </component>
> >
> > You have received NullPointerException somewhere in your listener code
> > because the object from direct link context is null.
> >
> > Sorry for my mistake
> >
> > Tsvetelin.
> 
> --
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 

-- 
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


RE: Help needed: DirectLink in a table

Posted by Mind Bridge <mi...@yahoo.com>.
Hi,

I think there is tiny error in the definition of the DirectLink component:

        <binding name="context" expression='user'/>

should be

        <binding name="parameters" expression='editDirectContext'/>

As described in the Component Reference, this should invoke the method
getEditDirectContext() to obtain the parameters of the DirectLink. Those
parameters are then used by the editDirectListener() method. At the moment
there are none, since the 'parameters' binding is not set, and hence you get
a null pointer exception.


Btw, just to let you know -- there is an additional example of exactly what
you need in the LocaleSelection component in the Workbench that achieves the
same result in a slightly different way. What was suggested, however, could
be simpler in many circumstances, so see if you can get it to work first.

Best regards,
-mb


-----Original Message-----
From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
Sent: Monday, August 25, 2003 4:17 PM
To: tsvetelin
Cc: Tapestry users
Subject: RE: Help needed: DirectLink in a table



Hello again,

I've updated the code according to all your comments today. Unfortunately,
I still get the same error:

Unable to invoke method editDirectListener on
lt.ktu.distance.elearn.pages.UsersPage@7fcd7e[Users]: null

The user in the actual edit method is still null. I'll paste all the
relevant code again, maybe someone can spot the mistake:

Maybe someone has all the files for such an example?

+-----------------------------------------------------+
The page specification:

<page-specification class="lt.ktu.distance.elearn.pages.UsersPage">
    <component id="tableView" type="contrib:TableView">
       <binding name="tableModel" expression="tableModel"/>
    </component>

    <component id="tableColumns" type="contrib:TableColumns">
    </component>

    <component id="tableRows" type="contrib:TableRows">
        <binding name="row" expression='user'/>
    </component>

    <component id="tableValues" type="contrib:TableValues">
    </component>

    <component id="editDirectLink" type="DirectLink">
        <binding name="context" expression='user'/>
        <binding name="listener"
expression='listeners.editDirectListener'/>
    </component>
</page-specification>
+-----------------------------------------------------+

+-----------------------------------------------------+
The Users.html file:
  <table jwcid="tableView" border="1" cellpadding="2" cellspacing="1">
    <tr>
        <span jwcid="tableColumns" />
        <th><p class="normal_text">Action</p></th>
    </tr>
    <tr jwcid="tableRows">
      <td jwcid="tableValues"/>
      <td >
        <a jwcid="editDirectLink">Edit</a>
      </td>
    </tr>
  </table>
+-----------------------------------------------------+

+-----------------------------------------------------+
The UsersPage.java:
public class UsersPage extends BasePage
{
    public ITableModel getTableModel()
    {
        ManagerFactory managerFactory = new ManagerFactory();
        UserManager userManager = managerFactory.createUserManager();

        Iterator users = userManager.loadUsers();

        ITableColumnModel objColumnModel =
                new ExpressionTableColumnModel(new String[]{
                    "Login", "login",
                    "Type", "type",
                    "First Name", "firstName",
                    "Last Name", "lastName",
                    "Email", "email",
                    "Phone", "phone",
                    "Address", "address",
                    "Occupation", "occupation",
                    "Organisation", "organisation"
                }, true);

        ArrayList userArrayList = new ArrayList();

        while (users.hasNext())
        {
            User user = (User) users.next();
            userArrayList.add(user);
        }

        return new SimpleTableModel(userArrayList.toArray(),
objColumnModel);
    }

    private User mUser = null;

    public User getUser()
    {
        return mUser;
    }

    public void setUser(User user)
    {
        mUser = user;
    }

    public Object[] getEditDirectContext()
    {
        return new Object[]{getUser().getId()};
    }

    public void editDirectListener(IRequestCycle cycle)
    {
        Object[] arrDirectParams = cycle.getServiceParameters();
        Object objObjectUID = (Integer)arrDirectParams[0]; // Null exception
is thrown here
    }
}
+-----------------------------------------------------+

Thanks,

> Sorry but I have made a small error in my example. In the definition of
> TableRows component the parameter "context" should be "row":
>     <component id="tableRows" type="contrib:TableRows">
>         <binding name="row" expression='user'/>
>     </component>
>
> And the parameter "row" of DirectLink should be "context"
>     <component id="editDirectLink" type="DirectLink">
>         <binding name="context" expression='user'/>
>         <binding name="listener"
> expression='listeners.editDirectListener'/>
>     </component>
>
> You have received NullPointerException somewhere in your listener code
> because the object from direct link context is null.
>
> Sorry for my mistake
>
> Tsvetelin.

--
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Help needed: DirectLink in a table

Posted by Mindaugas Genutis <mi...@elinara.ktu.lt>.
Hello again,

I've updated the code according to all your comments today. Unfortunately, 
I still get the same error:

Unable to invoke method editDirectListener on 
lt.ktu.distance.elearn.pages.UsersPage@7fcd7e[Users]: null

The user in the actual edit method is still null. I'll paste all the 
relevant code again, maybe someone can spot the mistake:

Maybe someone has all the files for such an example?

+-----------------------------------------------------+
The page specification:

<page-specification class="lt.ktu.distance.elearn.pages.UsersPage">
    <component id="tableView" type="contrib:TableView">
       <binding name="tableModel" expression="tableModel"/>
    </component>

    <component id="tableColumns" type="contrib:TableColumns">
    </component>

    <component id="tableRows" type="contrib:TableRows">
        <binding name="row" expression='user'/>
    </component>

    <component id="tableValues" type="contrib:TableValues">
    </component>

    <component id="editDirectLink" type="DirectLink">
        <binding name="context" expression='user'/>
        <binding name="listener" 
expression='listeners.editDirectListener'/>
    </component>
</page-specification>
+-----------------------------------------------------+

+-----------------------------------------------------+
The Users.html file:
  <table jwcid="tableView" border="1" cellpadding="2" cellspacing="1">
    <tr>
        <span jwcid="tableColumns" />
        <th><p class="normal_text">Action</p></th>
    </tr>
    <tr jwcid="tableRows">
      <td jwcid="tableValues"/>
      <td >
        <a jwcid="editDirectLink">Edit</a>
      </td>
    </tr>
  </table>
+-----------------------------------------------------+

+-----------------------------------------------------+
The UsersPage.java:
public class UsersPage extends BasePage
{
    public ITableModel getTableModel()
    {
        ManagerFactory managerFactory = new ManagerFactory();
        UserManager userManager = managerFactory.createUserManager();

        Iterator users = userManager.loadUsers();

        ITableColumnModel objColumnModel =
                new ExpressionTableColumnModel(new String[]{
                    "Login", "login",
                    "Type", "type",
                    "First Name", "firstName",
                    "Last Name", "lastName",
                    "Email", "email",
                    "Phone", "phone",
                    "Address", "address",
                    "Occupation", "occupation",
                    "Organisation", "organisation"
                }, true);

        ArrayList userArrayList = new ArrayList();

        while (users.hasNext())
        {
            User user = (User) users.next();
            userArrayList.add(user);
        }

        return new SimpleTableModel(userArrayList.toArray(), objColumnModel);
    }

    private User mUser = null;

    public User getUser()
    {
        return mUser;
    }

    public void setUser(User user)
    {
        mUser = user;
    }

    public Object[] getEditDirectContext()
    {
        return new Object[]{getUser().getId()};
    }

    public void editDirectListener(IRequestCycle cycle)
    {
        Object[] arrDirectParams = cycle.getServiceParameters();
        Object objObjectUID = (Integer)arrDirectParams[0]; // Null exception is thrown here
    }
}
+-----------------------------------------------------+

Thanks,

> Sorry but I have made a small error in my example. In the definition of
> TableRows component the parameter "context" should be "row":
>     <component id="tableRows" type="contrib:TableRows">
>         <binding name="row" expression='user'/>
>     </component>
> 
> And the parameter "row" of DirectLink should be "context"
>     <component id="editDirectLink" type="DirectLink">
>         <binding name="context" expression='user'/>
>         <binding name="listener"
> expression='listeners.editDirectListener'/>
>     </component>
> 
> You have received NullPointerException somewhere in your listener code
> because the object from direct link context is null.
> 
> Sorry for my mistake
> 
> Tsvetelin.

-- 
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


RE: Help needed: DirectLink in a table

Posted by tsvetelin <ts...@rushmore-digital.com>.
Hi Mindaugas,

Sorry but I have made a small error in my example. In the definition of
TableRows component the parameter "context" should be "row":
    <component id="tableRows" type="contrib:TableRows">
        <binding name="row" expression='user'/>
    </component>

And the parameter "row" of DirectLink should be "context"
    <component id="editDirectLink" type="DirectLink">
        <binding name="context" expression='user'/>
        <binding name="listener"
expression='listeners.editDirectListener'/>
    </component>

You have received NullPointerException somewhere in your listener code
because the object from direct link context is null.

Sorry for my mistake

Tsvetelin.

-----Original Message-----
From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
Sent: Monday, August 25, 2003 2:28 PM
To: tsvetelin
Cc: Tapestry users
Subject: Help needed: DirectLink in a table



Hello,

I can't make a simple user management page work. Below are extracted
relevant portions of my code. Tsvetelin suggested me to do it that way. I
would be very thankful if Tsvetelin or someone else point my mistake. At
the moment I get the following error:

Unable to invoke method editDirectListener on
lt.ktu.distance.elearn.pages.UsersPage@ebc2a2[Users]: null

The sytem isn't able to call the listener method. What I want to do is a
table with user list and an edit DirectLink in the last column which
forwards the request to the User Edit page.

Here's my HTML portion (Users.html):

+--------------------------------------------------------+
  <table jwcid="tableView">
    <tr>
        <span jwcid="tableColumns" />
        <th>Action</th>
    </tr>
    <tr jwcid="tableRows">
      <td jwcid="tableValues"/>
      <td >
        <a jwcid="editDirectLink">Edit</a>
      </td>
    </tr>
  </table>
+--------------------------------------------------------+

Here's the page specification (Users.page):

+--------------------------------------------------------+
<page-specification class="lt.ktu.distance.elearn.pages.UsersPage">
    <component id="tableView" type="contrib:TableView">
       <binding name="tableModel" expression="tableModel"/>
    </component>

    <component id="tableColumns" type="contrib:TableColumns">
    </component>

    <component id="tableRows" type="contrib:TableRows">
        <binding name="context" expression='user'/>
    </component>

    <component id="tableValues" type="contrib:TableValues">
    </component>

    <component id="editDirectLink" type="DirectLink">
        <binding name="row" expression='user'/>
        <binding name="listener"
expression='listeners.editDirectListener'/>
    </component>
</page-specification>
+--------------------------------------------------------+

Here's the page class (UsersPage.java extract):

+--------------------------------------------------------+
    private User mUser = null;

    public User getUser()
    {
        return mUser;
    }

    public void setUser(User user)
    {
        mUser = user;
    }

    public Object[] getEditDirectContext()
    {
        return new Object[]{getUser().getId()};
    }

    public void editDirectListener(IRequestCycle cycle)
    {
        Object[] arrDirectParams = cycle.getServiceParameters();
        Object objObjectUID = arrDirectParams[0];
        // implement your custom code for redirecting to page for editing
    }
+--------------------------------------------------------+

Thanks,

On Fri, 22 Aug 2003, tsvetelin wrote:

> Hi,
>
> You could obtain a object that represent a row from
> "org.apache.tapestry.contrib.table.components.TableRows.getTableRow();".
> There is a parameter "row" - so if you pass a binding to TableRows it will
> set every new row object into your binding.
>
> So in your page/component specification  you can define components like:
>
> .
> .
> .
>
>   <component id="TableRows " type="Contrib:TableRows ">
>     <binding name="context" expression='customRowObject'/>
>     .
>     .
>   </component>
>
>   <component id="editDirectLink" type="Direct">
>     <binding name="row" expression='editDirectContext'/>
>     <binding name="listener" expression='listeners.editDirectListener'/>
>   </component>
> .
> .
>
> In you Class file:
>
> .
> .
>   /**
>     * Don't forget to clean the state of this object after page detaching.
>     */
>   private CustomRowObject m_objRowObject = null;
>
>   public CustomRowObject getCustomRowObject(){
>       return m_objRowObject;
>   }
>
>   public void setCustomRowObject(CustomRowObject  objCustomRowObject){
>        m_objRowObject = objCustomRowObject;
>   }
>
>   public Object[] getEditDirectContext(){
>       return new Object[]{getCustomRowObject().getObjectUID()};
>   }
>
>   public void editDirectListener(IRequestCycle cycle){
>       Object[] arrDirectParams = cycle.getServiceParameters();
>       Object objObjectUID = arrDirectParams[0];
>       // implement your custom code for redirecting to page for editing
>   }
>
>
> Tsvetelin.
> -----Original Message-----
> From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> Sent: Friday, August 22, 2003 6:59 PM
> To: tsvetelin
> Cc: Tapestry users
> Subject: RE: Add a Form to the ITableColumnModel
>
>
>
> Thanks for the help,
>
> Yes, but how does the editDirectLink know which of the records should be
> edited? How to pass a record id to it from the tableValues?
>
> > Here is some short example (using tapestry 2.3 coding style) that add
> column
> > with edit link in the end of row:
> >
> >   <table jwcid="tableView">
> >     <span jwcid="condPages"><span jwcid="tablePages"/></span>
> >     <tr>
> >         <span jwcid="tableColumns"/>
> >         <th>Edit</th>
> >     </tr>
> >     <tr jwcid="tableRows">
> >       <td><span jwcid="checkButton"/></td>
> >       <td jwcid="tableValues"/>
> >       <td><a jwcid="editDirectLink">Edit</a></td>
> >     </tr>
> >   </table>
> >
> >
> > Tsvetelin.
> >
> > -----Original Message-----
> > From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> > Sent: Friday, August 22, 2003 5:44 PM
> > To: tapestry-user@jakarta.apache.org
> > Subject: Add a Form to the ITableColumnModel
> >
> >
> >
> > Hello,
> >
> > I'm using contrib:Table with ITableColumnModel to display application
> > data. I need to add action buttons on each record ("Edit", "Delete").
This
> > means I must put HTML forms inside the last Table column.
> >
> > Is it possible to give a form object to the ITableColumnModel? Will
Table
> > print it? If so, how to do it?
> >
> > Maybe this approach isn't very clean. Is there another way of doing
this?
> >
> > Thanks,
> >
> > --
> > Kaunas Regional Distance Education Center
> > Programmer
> > Phone: +370 674 05232
> > WWW: http://distance.ktu.lt
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
> --
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>

--
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Help needed: DirectLink in a table

Posted by Mindaugas Genutis <mi...@elinara.ktu.lt>.
Hello,

I can't make a simple user management page work. Below are extracted 
relevant portions of my code. Tsvetelin suggested me to do it that way. I 
would be very thankful if Tsvetelin or someone else point my mistake. At 
the moment I get the following error:

Unable to invoke method editDirectListener on 
lt.ktu.distance.elearn.pages.UsersPage@ebc2a2[Users]: null

The sytem isn't able to call the listener method. What I want to do is a 
table with user list and an edit DirectLink in the last column which 
forwards the request to the User Edit page.

Here's my HTML portion (Users.html):

+--------------------------------------------------------+
  <table jwcid="tableView">
    <tr>
        <span jwcid="tableColumns" />
        <th>Action</th>
    </tr>
    <tr jwcid="tableRows">
      <td jwcid="tableValues"/>
      <td >
        <a jwcid="editDirectLink">Edit</a>
      </td>
    </tr>
  </table>
+--------------------------------------------------------+

Here's the page specification (Users.page):

+--------------------------------------------------------+
<page-specification class="lt.ktu.distance.elearn.pages.UsersPage">
    <component id="tableView" type="contrib:TableView">
       <binding name="tableModel" expression="tableModel"/>
    </component>

    <component id="tableColumns" type="contrib:TableColumns">
    </component>

    <component id="tableRows" type="contrib:TableRows">
        <binding name="context" expression='user'/>
    </component>

    <component id="tableValues" type="contrib:TableValues">
    </component>

    <component id="editDirectLink" type="DirectLink">
        <binding name="row" expression='user'/>
        <binding name="listener" 
expression='listeners.editDirectListener'/>
    </component>
</page-specification>
+--------------------------------------------------------+

Here's the page class (UsersPage.java extract):

+--------------------------------------------------------+
    private User mUser = null;

    public User getUser()
    {
        return mUser;
    }

    public void setUser(User user)
    {
        mUser = user;
    }

    public Object[] getEditDirectContext()
    {
        return new Object[]{getUser().getId()};
    }

    public void editDirectListener(IRequestCycle cycle)
    {
        Object[] arrDirectParams = cycle.getServiceParameters();
        Object objObjectUID = arrDirectParams[0];
        // implement your custom code for redirecting to page for editing
    }
+--------------------------------------------------------+

Thanks,

On Fri, 22 Aug 2003, tsvetelin wrote:

> Hi,
> 
> You could obtain a object that represent a row from
> "org.apache.tapestry.contrib.table.components.TableRows.getTableRow();".
> There is a parameter "row" - so if you pass a binding to TableRows it will
> set every new row object into your binding.
> 
> So in your page/component specification  you can define components like:
> 
> .
> .
> .
> 
>   <component id="TableRows " type="Contrib:TableRows ">
>     <binding name="context" expression='customRowObject'/>
>     .
>     .
>   </component>
> 
>   <component id="editDirectLink" type="Direct">
>     <binding name="row" expression='editDirectContext'/>
>     <binding name="listener" expression='listeners.editDirectListener'/>
>   </component>
> .
> .
> 
> In you Class file:
> 
> .
> .
>   /**
>     * Don't forget to clean the state of this object after page detaching.
>     */
>   private CustomRowObject m_objRowObject = null;
> 
>   public CustomRowObject getCustomRowObject(){
> 	return m_objRowObject;
>   }
> 
>   public void setCustomRowObject(CustomRowObject  objCustomRowObject){
> 	 m_objRowObject = objCustomRowObject;
>   }
> 
>   public Object[] getEditDirectContext(){
> 	return new Object[]{getCustomRowObject().getObjectUID()};
>   }
> 
>   public void editDirectListener(IRequestCycle cycle){
> 	Object[] arrDirectParams = cycle.getServiceParameters();
> 	Object objObjectUID = arrDirectParams[0];
> 	// implement your custom code for redirecting to page for editing
>   }
> 
> 
> Tsvetelin.
> -----Original Message-----
> From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> Sent: Friday, August 22, 2003 6:59 PM
> To: tsvetelin
> Cc: Tapestry users
> Subject: RE: Add a Form to the ITableColumnModel
> 
> 
> 
> Thanks for the help,
> 
> Yes, but how does the editDirectLink know which of the records should be
> edited? How to pass a record id to it from the tableValues?
> 
> > Here is some short example (using tapestry 2.3 coding style) that add
> column
> > with edit link in the end of row:
> >
> >   <table jwcid="tableView">
> >     <span jwcid="condPages"><span jwcid="tablePages"/></span>
> >     <tr>
> >         <span jwcid="tableColumns"/>
> >         <th>Edit</th>
> >     </tr>
> >     <tr jwcid="tableRows">
> >       <td><span jwcid="checkButton"/></td>
> >       <td jwcid="tableValues"/>
> >       <td><a jwcid="editDirectLink">Edit</a></td>
> >     </tr>
> >   </table>
> >
> >
> > Tsvetelin.
> >
> > -----Original Message-----
> > From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> > Sent: Friday, August 22, 2003 5:44 PM
> > To: tapestry-user@jakarta.apache.org
> > Subject: Add a Form to the ITableColumnModel
> >
> >
> >
> > Hello,
> >
> > I'm using contrib:Table with ITableColumnModel to display application
> > data. I need to add action buttons on each record ("Edit", "Delete"). This
> > means I must put HTML forms inside the last Table column.
> >
> > Is it possible to give a form object to the ITableColumnModel? Will Table
> > print it? If so, how to do it?
> >
> > Maybe this approach isn't very clean. Is there another way of doing this?
> >
> > Thanks,
> >
> > --
> > Kaunas Regional Distance Education Center
> > Programmer
> > Phone: +370 674 05232
> > WWW: http://distance.ktu.lt
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> 
> --
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 

-- 
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


RE: Add a Form to the ITableColumnModel

Posted by tsvetelin <ts...@rushmore-digital.com>.
Hi,

You could obtain a object that represent a row from
"org.apache.tapestry.contrib.table.components.TableRows.getTableRow();".
There is a parameter "row" - so if you pass a binding to TableRows it will
set every new row object into your binding.

So in your page/component specification  you can define components like:

.
.
.

  <component id="TableRows " type="Contrib:TableRows ">
    <binding name="context" expression='customRowObject'/>
    .
    .
  </component>

  <component id="editDirectLink" type="Direct">
    <binding name="row" expression='editDirectContext'/>
    <binding name="listener" expression='listeners.editDirectListener'/>
  </component>
.
.

In you Class file:

.
.
  /**
    * Don't forget to clean the state of this object after page detaching.
    */
  private CustomRowObject m_objRowObject = null;

  public CustomRowObject getCustomRowObject(){
	return m_objRowObject;
  }

  public void setCustomRowObject(CustomRowObject  objCustomRowObject){
	 m_objRowObject = objCustomRowObject;
  }

  public Object[] getEditDirectContext(){
	return new Object[]{getCustomRowObject().getObjectUID()};
  }

  public void editDirectListener(IRequestCycle cycle){
	Object[] arrDirectParams = cycle.getServiceParameters();
	Object objObjectUID = arrDirectParams[0];
	// implement your custom code for redirecting to page for editing
  }


Tsvetelin.
-----Original Message-----
From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
Sent: Friday, August 22, 2003 6:59 PM
To: tsvetelin
Cc: Tapestry users
Subject: RE: Add a Form to the ITableColumnModel



Thanks for the help,

Yes, but how does the editDirectLink know which of the records should be
edited? How to pass a record id to it from the tableValues?

> Here is some short example (using tapestry 2.3 coding style) that add
column
> with edit link in the end of row:
>
>   <table jwcid="tableView">
>     <span jwcid="condPages"><span jwcid="tablePages"/></span>
>     <tr>
>         <span jwcid="tableColumns"/>
>         <th>Edit</th>
>     </tr>
>     <tr jwcid="tableRows">
>       <td><span jwcid="checkButton"/></td>
>       <td jwcid="tableValues"/>
>       <td><a jwcid="editDirectLink">Edit</a></td>
>     </tr>
>   </table>
>
>
> Tsvetelin.
>
> -----Original Message-----
> From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> Sent: Friday, August 22, 2003 5:44 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Add a Form to the ITableColumnModel
>
>
>
> Hello,
>
> I'm using contrib:Table with ITableColumnModel to display application
> data. I need to add action buttons on each record ("Edit", "Delete"). This
> means I must put HTML forms inside the last Table column.
>
> Is it possible to give a form object to the ITableColumnModel? Will Table
> print it? If so, how to do it?
>
> Maybe this approach isn't very clean. Is there another way of doing this?
>
> Thanks,
>
> --
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>

--
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Add a Form to the ITableColumnModel

Posted by Mindaugas Genutis <mi...@elinara.ktu.lt>.
Thanks for the help,

Yes, but how does the editDirectLink know which of the records should be 
edited? How to pass a record id to it from the tableValues?

> Here is some short example (using tapestry 2.3 coding style) that add column
> with edit link in the end of row:
> 
>   <table jwcid="tableView">
>     <span jwcid="condPages"><span jwcid="tablePages"/></span>
>     <tr>
>         <span jwcid="tableColumns"/>
>         <th>Edit</th>
>     </tr>
>     <tr jwcid="tableRows">
>       <td><span jwcid="checkButton"/></td>
>       <td jwcid="tableValues"/>
>       <td><a jwcid="editDirectLink">Edit</a></td>
>     </tr>
>   </table>
> 
> 
> Tsvetelin.
> 
> -----Original Message-----
> From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
> Sent: Friday, August 22, 2003 5:44 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Add a Form to the ITableColumnModel
> 
> 
> 
> Hello,
> 
> I'm using contrib:Table with ITableColumnModel to display application
> data. I need to add action buttons on each record ("Edit", "Delete"). This
> means I must put HTML forms inside the last Table column.
> 
> Is it possible to give a form object to the ITableColumnModel? Will Table
> print it? If so, how to do it?
> 
> Maybe this approach isn't very clean. Is there another way of doing this?
> 
> Thanks,
> 
> --
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 

-- 
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


RE: Add a Form to the ITableColumnModel

Posted by tsvetelin <ts...@rushmore-digital.com>.
Hi Mindaugas,

You could use another aproach. You could use a link instead buttons. You
shoud add additional header and colunm before/after colunms defined from
ITableColumnModel. In this case you do not need from form before table.

Here is some short example (using tapestry 2.3 coding style) that add column
with edit link in the end of row:

  <table jwcid="tableView">
    <span jwcid="condPages"><span jwcid="tablePages"/></span>
    <tr>
        <span jwcid="tableColumns"/>
        <th>Edit</th>
    </tr>
    <tr jwcid="tableRows">
      <td><span jwcid="checkButton"/></td>
      <td jwcid="tableValues"/>
      <td><a jwcid="editDirectLink">Edit</a></td>
    </tr>
  </table>


Tsvetelin.

-----Original Message-----
From: Mindaugas Genutis [mailto:mindaugas@elinara.ktu.lt]
Sent: Friday, August 22, 2003 5:44 PM
To: tapestry-user@jakarta.apache.org
Subject: Add a Form to the ITableColumnModel



Hello,

I'm using contrib:Table with ITableColumnModel to display application
data. I need to add action buttons on each record ("Edit", "Delete"). This
means I must put HTML forms inside the last Table column.

Is it possible to give a form object to the ITableColumnModel? Will Table
print it? If so, how to do it?

Maybe this approach isn't very clean. Is there another way of doing this?

Thanks,

--
Kaunas Regional Distance Education Center
Programmer
Phone: +370 674 05232
WWW: http://distance.ktu.lt


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org