You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Karr, David" <da...@wamu.net> on 2008/03/02 21:24:42 UTC

Qs about Ajax abilities in Struts 2

I've been out of the Struts loop for a long time now (some of you old
timers should remember me).  I've been reading the docs in firehose mode
the last few days, but I have some questions about Ajax-related
capabilities in the latest release.  I'd like to see if certain
combinations of features are viable, and any issues or guidelines
towards implementing those capabilities.

I'd like to see a page with a data table and a tabbed panel.  The data
in the table row would be populated from data fields in a tab.  A button
on the table will add a new empty row to the table (there would also be
a "delete row" function).

Below the data table is a tabbed panel, where the first tab and the last
tab are "static", with specific fields in those two tabs.  When the "add
row" button on the table is pressed, it will add the data table row and
also dynamically add a tab to the tabbedpanel.  Each of the added
"dynamic" tabs will all have the same fields, but with different values
associated with a "primary key".

In the JSP, it would be nice if the "dynamic" tabs were rendered with
some sort of a repeat loop.  Alternatively, a certain "maximum" number
of dynamic tabs could be unrendered initially, with local actions
causing them to be rendered (and populated).

One of the tabs would have a "Submit" button which would submit all the
data entered in all the tabs.  The action on that button is about the
only action that would cause a full page refresh.  Everything else would
be local actions.

So, is this viable in the latest Struts release?  Are there any obvious
problems or issues I should expect to run into while implementing this?

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


Re: Qs about Ajax abilities in Struts 2

Posted by mg...@hotmail.com.
most recent version of Dojo 1.0 has a datatable control

 <div dojoType="dijit.layout.ContentPane" sizeMin="50" sizeShare="50">
     <div class="dataTable" dojoType="dojox.wire.demos.TableContainer"
jsId="dataTable" headers="Name,Location Type">
     </div>
		</div>

<div dojoType="dojo.data.ItemFileReadStore"
		jsId="DataStore1"
		url="countries.json">
</div>dataHolder = {
			//Simple object definition to get all items and sort it by the attribute
'type'.
			request: {query: {name: "*"}, onItem: function(item, req){}, sort:
[{attribute: "type"}]},
			//Spot to store off data values as they're generated by the declarative
binding.
			result: null
		};<div dojoType="dojox.wire.ml.Action"
		trigger="searchButton"
		triggerEvent="onClick">
		<div dojoType="dojox.wire.ml.Invocation" object="dataTable"
method="clearTable"></div>
		<div dojoType="dojox.wire.ml.Invocation" object="DataStore1"
method="fetch" parameters="dataHolder.request"></div></div>where
countries.json contains the following json formatted array{ identifier:
'name',   items: [  { name:'Africa', type:'continent',
children:[{_reference:'Egypt'}, {_reference:'Kenya'},
{_reference:'Sudan'}] },  { name:'Egypt', type:'country' },  { name:'Kenya',
type:'country',   children:[{_reference:'Nairobi'},
{_reference:'Mombasa'}] },  { name:'Nairobi', type:'city' },  {
name:'Mombasa', type:'city' },  { name:'Sudan', type:'country',
children:{_reference:'Khartoum'} },  { name:'Khartoum', type:'city' },  {
name:'Asia', type:'continent',   children:[{_reference:'China'},
{_reference:'India'}, {_reference:'Russia'}, {_reference:'Mongolia'}] },
{ name:'China', type:'country' },  { name:'India', type:'country' },  {
name:'Russia', type:'country' },  { name:'Mongolia', type:'country' },  {
name:'Australia', type:'continent', population:'21 million',
children:{_reference:'Commonwealth of Australia'}},  { name:'Commonwealth of
Australia', type:'country', population:'21 million'},  { name:'Europe',
type:'continent',   children:[{_reference:'Germany'}, {_reference:'France'},
{_reference:'Spain'}, {_reference:'Italy'}] },  { name:'Germany',
type:'country' },  { name:'France', type:'country' },  { name:'Spain',
type:'country' },  { name:'Italy', type:'country' },  { name:'North
America', type:'continent',   children:[{_reference:'Mexico'},
{_reference:'Canada'}, {_reference:'United States of America'}] },  {
name:'Mexico', type:'country',  population:'108 million', area:'1,972,550 sq
km',   children:[{_reference:'Mexico City'}, {_reference:'Guadalajara'}] },
{ name:'Mexico City', type:'city', population:'19 million', timezone:'-6
UTC'},  { name:'Guadalajara', type:'city', population:'4 million',
timezone:'-6 UTC' },  { name:'Canada', type:'country',  population:'33
million', area:'9,984,670 sq km',   children:[{_reference:'Ottawa'},
{_reference:'Toronto'}] },  { name:'Ottawa', type:'city', population:'0.9
million', timezone:'-5 UTC'},  { name:'Toronto', type:'city',
population:'2.5 million', timezone:'-5 UTC' },  { name:'United States of
America', type:'country' },  { name:'South America', type:'continent',
children:[{_reference:'Brazil'}, {_reference:'Argentina'}] },  {
name:'Brazil', type:'country', population:'186 million' },  {
name:'Argentina', type:'country', population:'40 million' }]}Anyone feel up
to incorporating this into the dojo wrapper ftl/xml/struts-tag?

?
Martin-
----- Original Message -----
Wrom: QTIPWIGYOKSTTZRCLBDXRQBGJSNBOHMKHJYFMYXOEAIJJPHSC
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Sunday, March 02, 2008 7:45 PM
Subject: Re: Qs about Ajax abilities in Struts 2


> Yes, it's completely viable with Struts 2, however, the majority of what
> you've described is client-side functionality. What you need is a good
> client-side library.
>
> I wouldn't approach this problem using the Struts 2 dojo/ajax tags *at
> all*.  They're too limited, especially as they're without a datatable
> component and because you need to write javascript to bind these
> components together.
>
> I've used YUI to do similar to what you've described (see DataTable and
> TabView) [1]. It's incredible how simple it is.  I'm certain Dojo 1.x
> will support it too, as too every other current-day rich-client
> library.  You just need to look at these, and others, and choose which
> client-side architecture you prefer.
>
> Using struts 2 is the easy bit.
>
> [1] http://developer.yahoo.com/yui/
> [2] http://www.dojotoolkit.org/
>
> Karr, David wrote:
> > I've been out of the Struts loop for a long time now (some of you old
> > timers should remember me).  I've been reading the docs in firehose mode
> > the last few days, but I have some questions about Ajax-related
> > capabilities in the latest release.  I'd like to see if certain
> > combinations of features are viable, and any issues or guidelines
> > towards implementing those capabilities.
> >
> > I'd like to see a page with a data table and a tabbed panel.  The data
> > in the table row would be populated from data fields in a tab.  A button
> > on the table will add a new empty row to the table (there would also be
> > a "delete row" function).
> >
> > Below the data table is a tabbed panel, where the first tab and the last
> > tab are "static", with specific fields in those two tabs.  When the "add
> > row" button on the table is pressed, it will add the data table row and
> > also dynamically add a tab to the tabbedpanel.  Each of the added
> > "dynamic" tabs will all have the same fields, but with different values
> > associated with a "primary key".
> >
> > In the JSP, it would be nice if the "dynamic" tabs were rendered with
> > some sort of a repeat loop.  Alternatively, a certain "maximum" number
> > of dynamic tabs could be unrendered initially, with local actions
> > causing them to be rendered (and populated).
> >
> > One of the tabs would have a "Submit" button which would submit all the
> > data entered in all the tabs.  The action on that button is about the
> > only action that would cause a full page refresh.  Everything else would
> > be local actions.
> >
> > So, is this viable in the latest Struts release?  Are there any obvious
> > problems or issues I should expect to run into while implementing this?
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: Qs about Ajax abilities in Struts 2

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Yes, it's completely viable with Struts 2, however, the majority of what 
you've described is client-side functionality. What you need is a good 
client-side library.

I wouldn't approach this problem using the Struts 2 dojo/ajax tags *at 
all*.  They're too limited, especially as they're without a datatable 
component and because you need to write javascript to bind these 
components together.

I've used YUI to do similar to what you've described (see DataTable and 
TabView) [1]. It's incredible how simple it is.  I'm certain Dojo 1.x 
will support it too, as too every other current-day rich-client 
library.  You just need to look at these, and others, and choose which 
client-side architecture you prefer.

Using struts 2 is the easy bit.

[1] http://developer.yahoo.com/yui/
[2] http://www.dojotoolkit.org/

Karr, David wrote:
> I've been out of the Struts loop for a long time now (some of you old
> timers should remember me).  I've been reading the docs in firehose mode
> the last few days, but I have some questions about Ajax-related
> capabilities in the latest release.  I'd like to see if certain
> combinations of features are viable, and any issues or guidelines
> towards implementing those capabilities.
>
> I'd like to see a page with a data table and a tabbed panel.  The data
> in the table row would be populated from data fields in a tab.  A button
> on the table will add a new empty row to the table (there would also be
> a "delete row" function).
>
> Below the data table is a tabbed panel, where the first tab and the last
> tab are "static", with specific fields in those two tabs.  When the "add
> row" button on the table is pressed, it will add the data table row and
> also dynamically add a tab to the tabbedpanel.  Each of the added
> "dynamic" tabs will all have the same fields, but with different values
> associated with a "primary key".
>
> In the JSP, it would be nice if the "dynamic" tabs were rendered with
> some sort of a repeat loop.  Alternatively, a certain "maximum" number
> of dynamic tabs could be unrendered initially, with local actions
> causing them to be rendered (and populated).
>
> One of the tabs would have a "Submit" button which would submit all the
> data entered in all the tabs.  The action on that button is about the
> only action that would cause a full page refresh.  Everything else would
> be local actions.
>
> So, is this viable in the latest Struts release?  Are there any obvious
> problems or issues I should expect to run into while implementing this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>   


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