• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts / Tiles - changing which layout is used at runtime

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

(using struts 1.3.8)

I've written some form pages. The forms are generated by actions and appear in my final rendered page via a Tiles 'content' section. Now, I want to make the form AJAX enabled (while keeping the underlying non-ajax functionality). I think I have a handle on how that will work... my problem is, I want to reuse the actions that are currently generating the Tiles 'content' element (my simple 'AJAX' process: user clicks a submit button, I use javascript to send the request to the server, get back JUST THE CONTENT section and update my innerHTML (or whatever) with that text). - But my actions are tied to a layout that displays a header/footer/menu/etc... I want just the content - which is what my action is generating.

I've done some testing and can call the actions via javascript (AJAX) - and I'm able to pass an additional parameter (AJAX=1 - not that I expect that to do anything - I just know I have a switch available)... but what is returned to me is the entire page (as I expect - but don't want!).

I really don't want to write an entire new set of actions - to tie them to a simplified layout (i.e. just the 'content')

Ideally, I'd like to be able to determine (within my action code) which layout to use... but I fear it is too late in the process to do that.

My actions are tied to the Tile/layout by (I think) my input=gymMaintenance.page (i believe this may be part of the problem/solution) - below are 2 of my a action definitions:



This is my tile/layout definition:


If I could just override that "extends='layout_b'" with (something like) "extends='contentOnlyLayout'" at runtime, based on my switch AJAX=1

I'm new to Struts and Java... hope I'm making some sense!

Thanks,

bill g
 
Ranch Hand
Posts: 213
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, if you are new to Struts why are you leasrning an old version and not the latest version?

As to your problem, no, you cannot do an override.

From what I can gather about your question it looks like you want to submit the form but then only have the "content" tiles section refreshed. If that's what you want to do then you need to make if so your content, gymMaintenance.jsp, can be refreshed using AJAX. That will be the only way you can change the content only.
 
will gillingham
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok - so there is a solution. First, I had to change my struts config to NOT associate the page with a layout/template. Next, I had to create a stub jsp file that would examine my parameter 'AJAX=1' - depending on the value, the stub file chooses the definition:

gymMaintenanceStub.jsp:


My actions now point to the stub page (gymMaintenanceStub.jsp) and each of the above mentioned tile definitions point to my original jsp page for their content section:



Everything works fine - validation, ActionForm is accessible... there was no further work needed on the server.

thanks,

bill g
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic