You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frans Thamura <fr...@meruvian.org> on 2008/04/06 10:52:48 UTC

Multiple Result in one Page

hi all,

I am try to develop a web apps using Struts2, and the presentation we use
ExtJS.

in ExtJS, we have a form that represent 1 table, and several grid, around
2-3 table grids.

so, in my mind the grid = one result...

after trying several model, i see that every form or table grid need 1
result

in my case above, we need 3-4 result

for me, creating 4 results for 1 page is an annoying job and make my
struts.xml become blowup and dirty.

any idea guys?

F

Re: Noob question(s). Interceptor breaking forms, and Connection handling?

Posted by Dave Newton <ne...@yahoo.com>.
--- Dave Belfer-Shevett <db...@homeport.org> wrote:
> I have a Logon form that works fine without an interceptor, but as soon 
> as I add one, my getUsername() and other methods fail (the username is 
> null).

When you declare interceptor-refs for an action you are declaring *all* the
interceptors for that action. You either need to create a *complete* stack
with your interceptor included or specify *all* the interceptors your action
requires.

> Question 2...
> I tried doing this, and saw the connection start up, but the Action 
> class kept having the connection as 'null'.  I think I'm either 
> misunderstanding how the interceptor / action sequence works, or doing 
> something blatantly stupid.

Without the actual implementation it will be difficult to help.

What you probably meant in the code above was that you'd check for an
interface that informs the interceptor that the action accepts a connection
property. If the action being invoked implements the interface, get the
connection and set it on the action. If you look at many of the S2/XWork
interceptor source you'll see this technique used all over the place.

That's certainly one way to handle connections.

Dave


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


Noob question(s). Interceptor breaking forms, and Connection handling?

Posted by Dave Belfer-Shevett <db...@homeport.org>.
Hi folks, I have two questions, and I apologize for the n00b approach. 
I'm just teaching myself struts2, coming from a PHP background (but I've 
done plenty of JEE and Java Swing programming, so the language isn't 
completely alien :)

Question 1...

I have a Logon form that works fine without an interceptor, but as soon 
as I add one, my getUsername() and other methods fail (the username is 
null).

Struts.xml:
http://pastebin.stonekeep.com/1893

DBInterceptor:
http://pastebin.stonekeep.com/1894

Logon.java:
http://pastebin.stonekeep.com/1895

If I uncomment the interceptor line in my struts.xml file, the Logon 
form validator fails.  Line 29 shows 'null' in Logon.java.  If i leave 
it commented out, it works fine.

Question 2...

In Logon.java, I'm using the execute() method to set up my JDBC 
connection (as pulled from my JBoss container datasource), setting up 
the Connection, and making the call.  Wouldn't it make more sense to do 
that in an interceptor around every class, and do something like

         ic = new InitialContext();
         dataSource = (DataSource)ic.lookup("java:JQuoDEV");
         c = dataSource.getConnection();
	Logon action = (Logon)invocation.getAction();
	action.connection = c;
	return invocation.invoke() ;

I tried doing this, and saw the connection start up, but the Action 
class kept having the connection as 'null'.  I think I'm either 
misunderstanding how the interceptor / action sequence works, or doing 
something blatantly stupid.

Help?

	-dbs

--
Dave Belfer-Shevet
Stonekeep Consulting, Inc
http://www.stonekeep.com/

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


Re: Multiple Result in one Page

Posted by Frans Thamura <fr...@meruvian.org>.
> The JSON plugin is stable in all respects except that it hasn't been
> released as a 1.x.  I use it a lot and haven't encountered any problems
> since adding enum support.
>

we are finding this issue also.

>
> However the REST Plugin itself actually uses json-lib:
> http://json-lib.sourceforge.net/.  I haven't had a change to compare it
> yet, but if it is truly based on Douglas Crockford's work then I'll propose
> changing the JSON plugin to use json-lib to generate the JSON (or at least
> allow it to be plugged in as an alternative serializer)


that will be cool, but i dont know, how to write a plugins using this api

i am very close with the creator of json-lib, andre almiray (CMIIW)

> .
>

Re: Multiple Result in one Page

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Frans Thamura wrote:
>
> right,
>
> i think that it is nice they separated view meta to create the form, and
> model meta to fill the value in the input form inside form
>
> but.. if we move all of our project, the json plugins is not stable version,
>
> will this make the code of mine become unstable
>
>
> that will be nice if there is REST with json output...
>
> F
>
>   

The JSON plugin is stable in all respects except that it hasn't been 
released as a 1.x.  I use it a lot and haven't encountered any problems 
since adding enum support.

However the REST Plugin itself actually uses json-lib:  
http://json-lib.sourceforge.net/.  I haven't had a change to compare it 
yet, but if it is truly based on Douglas Crockford's work then I'll 
propose changing the JSON plugin to use json-lib to generate the JSON 
(or at least allow it to be plugged in as an alternative serializer).


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


Re: Multiple Result in one Page

Posted by Frans Thamura <fr...@meruvian.org>.
On Tue, Apr 8, 2008 at 6:07 AM, Jeromy Evans <
jeromy.evans@blueskyminds.com.au> wrote:

> Does that mean ExtFS can build a form from a json (or xml) specification?
>  I've needed that myself.
>
> I don't see anything wrong with your approach.  In fact I like it. The
> view (form) is nice separated from the model (data).
>
>
right,

i think that it is nice they separated view meta to create the form, and
model meta to fill the value in the input form inside form

but.. if we move all of our project, the json plugins is not stable version,

will this make the code of mine become unstable


that will be nice if there is REST with json output...

F

Re: Multiple Result in one Page

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Does that mean ExtFS can build a form from a json (or xml) 
specification?  I've needed that myself.

I don't see anything wrong with your approach.  In fact I like it. The 
view (form) is nice separated from the model (data).

Frans Thamura wrote:
> take a look of this
>
> http://farm3.static.flickr.com/2018/2394469980_a9984272d8.jpg?v=0
>
> this is our current approach, a s2 action for form, and another action for
> value
>
> i use the ExtJS, and run well here :)
>
> thx to the ExtJs GUI Designer team
>
> but i am seeking another cool stuff that beter.
>
>
> Frans
>
> On Mon, Apr 7, 2008 at 10:08 AM, Jeromy Evans <
> jeromy.evans@blueskyminds.com.au> wrote:
>
>   
>> I'm not completely sure what you mean but two things come to mind:
>> - the s:action tag is useful for pages that need to be assembled using the
>> results from multiple actions.  If each each outputs a component of the
>> view, you can uses Tiles or Sitemesh to assemble a page on the server-side
>> that invokes numerous actions.  You can then reuse the components and design
>> actions around each data model instead of each page.
>> - as you're using ExtJS, you can use the same pattern as described above,
>> but invoke each action XHR.  The page can be assembled via ExtJS on the
>> client-side with your actions returning data or html fragments as
>> appropriate.
>>
>>
>>
>>     
>
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.519 / Virus Database: 269.22.8/1362 - Release Date: 6/04/2008 11:12 AM
>   


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


Re: Multiple Result in one Page

Posted by Frans Thamura <fr...@meruvian.org>.
take a look of this

http://farm3.static.flickr.com/2018/2394469980_a9984272d8.jpg?v=0

this is our current approach, a s2 action for form, and another action for
value

i use the ExtJS, and run well here :)

thx to the ExtJs GUI Designer team

but i am seeking another cool stuff that beter.


Frans

On Mon, Apr 7, 2008 at 10:08 AM, Jeromy Evans <
jeromy.evans@blueskyminds.com.au> wrote:

> I'm not completely sure what you mean but two things come to mind:
> - the s:action tag is useful for pages that need to be assembled using the
> results from multiple actions.  If each each outputs a component of the
> view, you can uses Tiles or Sitemesh to assemble a page on the server-side
> that invokes numerous actions.  You can then reuse the components and design
> actions around each data model instead of each page.
> - as you're using ExtJS, you can use the same pattern as described above,
> but invoke each action XHR.  The page can be assembled via ExtJS on the
> client-side with your actions returning data or html fragments as
> appropriate.
>
>
>

Re: Multiple Result in one Page

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
I'm not completely sure what you mean but two things come to mind:
 - the s:action tag is useful for pages that need to be assembled using 
the results from multiple actions.  If each each outputs a component of 
the view, you can uses Tiles or Sitemesh to assemble a page on the 
server-side that invokes numerous actions.  You can then reuse the 
components and design actions around each data model instead of each page.
 - as you're using ExtJS, you can use the same pattern as described 
above, but invoke each action XHR.  The page can be assembled via ExtJS 
on the client-side with your actions returning data or html fragments as 
appropriate.

Frans Thamura wrote:
> hi all,
>
> I am try to develop a web apps using Struts2, and the presentation we use
> ExtJS.
>
> in ExtJS, we have a form that represent 1 table, and several grid, around
> 2-3 table grids.
>
> so, in my mind the grid = one result...
>
> after trying several model, i see that every form or table grid need 1
> result
>
> in my case above, we need 3-4 result
>
> for me, creating 4 results for 1 page is an annoying job and make my
> struts.xml become blowup and dirty.
>
> any idea guys?
>
> F
>
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.519 / Virus Database: 269.22.7/1361 - Release Date: 5/04/2008 7:53 AM
>   


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