You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jack Axaopoulos <ja...@cisco.com> on 2002/01/23 19:21:51 UTC

Action overriding layouts?

Is it possible for a Velocity action which is called
to override which layout will be used?

I noticed that RunData implements setLayoutTemplate(),
but it doesn't seem to be used anywhere.

Here is what I'm trying to accomplish.

Say a user fills in some form data, but there is an error,
and you want to display the exact same form
but with a new error message being shown above the form in red.

I was hoping to dynamically switch to an ErrorMessageLayout.vm
which simply adds a $UserErrorMessage variable and contains
$screen_placeholder where the original screen/form would appear.

What is a typical Turbine/Velocity pattern for handling this?



Im using Turbine 2.1 and Velocity 1.2.

Regards,

J


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Action overriding layouts?

Posted by Scott Eade <se...@backstagetech.com.au>.
For what you are describing you should look into the intake service.

You would only use a single layout, and the red errors would only
appear when values had been set by intake.

I think there is a howto on the Turbine site.

HTH,

Scott

----- Original Message -----
From: "Jack Axaopoulos" <ja...@cisco.com>
To: <tu...@jakarta.apache.org>
Sent: Thursday, January 24, 2002 5:21 AM
Subject: Action overriding layouts?


>
> Is it possible for a Velocity action which is called
> to override which layout will be used?
>
> I noticed that RunData implements setLayoutTemplate(),
> but it doesn't seem to be used anywhere.
>
> Here is what I'm trying to accomplish.
>
> Say a user fills in some form data, but there is an error,
> and you want to display the exact same form
> but with a new error message being shown above the form in red.
>
> I was hoping to dynamically switch to an ErrorMessageLayout.vm
> which simply adds a $UserErrorMessage variable and contains
> $screen_placeholder where the original screen/form would appear.
>
> What is a typical Turbine/Velocity pattern for handling this?
>
>
>
> Im using Turbine 2.1 and Velocity 1.2.
>
> Regards,
>
> J
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Action overriding layouts?

Posted by "david.wynter@btclick.com" <da...@btclick.com>.
I just re read some of the docs today and this question is answered. See the
section under Actions in
http://jakarta.apache.org/turbine/turbine-2/howto/velocity-site-howto.html

David
-----Original Message-----
From: Jack Axaopoulos [mailto:jaxaopou@cisco.com]
Sent: 23 January 2002 18:22
To: turbine-user@jakarta.apache.org
Subject: Action overriding layouts?



Is it possible for a Velocity action which is called
to override which layout will be used?

I noticed that RunData implements setLayoutTemplate(),
but it doesn't seem to be used anywhere.

Here is what I'm trying to accomplish.

Say a user fills in some form data, but there is an error,
and you want to display the exact same form
but with a new error message being shown above the form in red.

I was hoping to dynamically switch to an ErrorMessageLayout.vm
which simply adds a $UserErrorMessage variable and contains
$screen_placeholder where the original screen/form would appear.

What is a typical Turbine/Velocity pattern for handling this?



Im using Turbine 2.1 and Velocity 1.2.

Regards,

J


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Dueling layouts

Posted by Jeffery Painter <pa...@kiasoft.com>.
works fine for me on tdk-2.1

eg.

public class NewLayout extends VelocityScreen
{
    public void doBuildTemplate( RunData data, Context context )
    {
        data.setLayoutTemplate("/PtLayout.vm");
	context.put("msg", "test...");
    }
}


./templates/app/screens/NewLayout.vm
<!-- begin -->
  $msg
<!-- end -->

./templates/app/layouts/PtLayout.vm
<!-- begin -->

 $page.setBgColor("#0000ff") <!-- blue -->
 $screen_placeholder

<!-- end -->

sounds like you might still have an old  $navigation.setTemplate() call in 
your layout screen pulling in defaultTop and bottom.. you don't _need_ 
these, they are just the defaults that came with turbine templates.

$screen_placeholder is all you really _need_ the <html>, <head> and body 
tags are the only thing that is auto-generated from turbine, the rest is 
pieced together by you.

Jeff Painter


On Wed, 29 Jan 2003, Bruce Altner wrote:

> FWIW, I couldn't get setLayoutTemplate to work in the Screen class. Is that 
> a Turbine 2.2 thing (I'm still using 2.1)?
> 
> Anyway, I was able to accomplish what I wanted, finally, by overriding the 
> DefaultTopNavigation and DefaultBottomNavigation classes. There has to be a 
> better way to do this, though.
> 
> Bruce
> 



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


Re: Dueling layouts

Posted by Bruce Altner <ba...@hq.nasa.gov>.
FWIW, I couldn't get setLayoutTemplate to work in the Screen class. Is that 
a Turbine 2.2 thing (I'm still using 2.1)?

Anyway, I was able to accomplish what I wanted, finally, by overriding the 
DefaultTopNavigation and DefaultBottomNavigation classes. There has to be a 
better way to do this, though.

Bruce


At 10:03 PM 1/28/2003, you wrote:
>Bruce Altner <ba...@hq.nasa.gov> writes:
>
> > Greetings:
> >
> > I have a link on a main page that uses javascript to pop up a small
> > window containing another template, popup.vm.
> > The main page uses Default.vm as a layout but this is not appropriate
> > in a small popup window so I have popup.vm call
> > a different layout. Problem is, this overrides the Default layout in 
> main.vm.
> >
> > This surprised me since these are two separate windows but I guess
> > Turbine doesn't care. Is there a way to force Turbine to use
> > different layouts for different windows?
>
>I believe all you have to do is name your layout template the same as your 
>screen template.  So if your screen vm name is screens/popup.vm your could 
>have a layouts/popup.vm, if names don't match, the Default.vm layout 
>template is used.
>
>--
>=====================================================================
>Jeffrey D. Brekke                                   jbrekke@wi.rr.com
>Wisconsin,  USA                                     brekke@apache.org
>                                                     ekkerbj@yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-user-help@jakarta.apache.org



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


Problem with addjoin

Posted by Keshava Murthy <ke...@bigtec.org>.
Hi ,
The following method in screen class returns the data without any problem if
the database used is Oracle 8i and when I change the database to mysql the
method returns null value.

private Vector getPatientRegnData(){
 try
 {
String strPin="1";
 String strEncNo="1";
 Criteria criteria          =  new Criteria();

/* columns from his_mas_patregn table /*


criteria.addJoin(HisMasPatregnPeer.IPAT_INO_PREG,HisTrxPatrevisitPeer.IPAT_I
NO_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_INO_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_TITLE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_FNAME_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_MNAME_PREG );
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_LNAME_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_SEX_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.DTPAT_DOB_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_TYPE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_BLDGRP_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_IDFNMARKS_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_MRLSTS_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_ADDR_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_AREA_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_CITY_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_STATE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_CTRY_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_ZIP_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_PHONE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_ATNDOC_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IPAT_REFBY_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.SPAT_NOTES_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.DTPAT_REGDT_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.DTCRT_DATE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.DTMDF_DATE_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.ICRT_BY_PREG);
 criteria.addSelectColumn(HisMasPatregnPeer.IMDF_BY_PREG);

/* columns from his_trx_patrevisit table /*

 criteria.addSelectColumn(HisTrxPatrevisitPeer.IPAT_ENCNO_PRVT);
 criteria.addSelectColumn(HisTrxPatrevisitPeer.DTPAT_RVTDTTM_PRVT);

 Criteria.Criterion a1  =
criteria.getNewCriterion(HisMasPatregnPeer.IPAT_INO_PREG,strPin,Criteria.LIK
E);
 Criteria.Criterion b1  =
criteria.getNewCriterion(HisTrxPatrevisitPeer.IPAT_ENCNO_PRVT,strEncNo,Crite
ria.LIKE);
 criteria.add(a1.and(b1));
  return HisMasPatregnPeer.doPSSelect(criteria);
 }
 catch (Exception e)
 {
 return null;
}
}

I also did some debugging and found that if I comment columns from
his_trx_patrevisit table the method returns vector conatins data.
I also checked the sql query generated(criteria.toString()) from mysql
prompt and it returns proper data, which means that addjoin query is not
working in mysql  and it is working properly when oracle is the database
when application is run.

My question is why it is returning vector containg null  when I use mysql as
database?

regards,
Keshava Murthy. S



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


Re: Dueling layouts

Posted by "Jeffrey D. Brekke" <jb...@wi.rr.com>.
Bruce Altner <ba...@hq.nasa.gov> writes:

> Greetings:
> 
> I have a link on a main page that uses javascript to pop up a small
> window containing another template, popup.vm.
> The main page uses Default.vm as a layout but this is not appropriate
> in a small popup window so I have popup.vm call
> a different layout. Problem is, this overrides the Default layout in main.vm.
> 
> This surprised me since these are two separate windows but I guess
> Turbine doesn't care. Is there a way to force Turbine to use
> different layouts for different windows?

I believe all you have to do is name your layout template the same as your screen template.  So if your screen vm name is screens/popup.vm your could have a layouts/popup.vm, if names don't match, the Default.vm layout template is used.

-- 
=====================================================================
Jeffrey D. Brekke                                   jbrekke@wi.rr.com
Wisconsin,  USA                                     brekke@apache.org
                                                    ekkerbj@yahoo.com

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


Re: Dueling layouts

Posted by Jeffery Painter <pa...@kiasoft.com>.
Are you extending this screen as a SecureScreen or simple VelocityScreen?

more code snippets might lead to a clue.

Jeff Painter

On Tue, 28 Jan 2003, Bruce Altner wrote:

> Thanks for the hint. I wasn't using a Screen class but rather overriding 
> the layout with $data.setLayoutTemplate in the template.
> 
> So now I have it that I don't get Default.vm but still the Screen seems to 
> ignore the template I'm telling it to use. Instead I get some
> Uber-default layout with "Turbine - A Servlet Framework for building Secure 
> Dynamic Websites." in the top and the same message and a logout button on 
> the bottom.
> 
> I'm using  data.setLayoutTemplate("/Sparse.vm") but it is being ignored.
> 
> Almost there but not quite...
> 
> 
> Thanks.
> 
> Bruce
> 


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


Re: Dueling layouts

Posted by Bruce Altner <ba...@hq.nasa.gov>.
Thanks for the hint. I wasn't using a Screen class but rather overriding 
the layout with $data.setLayoutTemplate in the template.

So now I have it that I don't get Default.vm but still the Screen seems to 
ignore the template I'm telling it to use. Instead I get some
Uber-default layout with "Turbine - A Servlet Framework for building Secure 
Dynamic Websites." in the top and the same message and a logout button on 
the bottom.

I'm using  data.setLayoutTemplate("/Sparse.vm") but it is being ignored.

Almost there but not quite...


Thanks.

Bruce

At 04:32 PM 1/28/2003, you wrote:
>I have done this with no problem. I needed to create a
>"PrinterFriendly.vm" and layout which is totally seperate from the regular
>site.
>
>My pop up is called from javascript / velocity generated url
>
>  http://valentinedesigngroup.com - working example
>
>I have a class in project.screens.PrintOut.java that calls
>
>  data.setLayoutTemplate("/PrinterFriendly.vm");
>
>I did find that you need to make sure your template has a "unique" name...
>if it is called the same as your screen file, then this will cause turbine
>to become confused.
>
>main.vm should call your default template set in your TR.props, but if you
>really want to be sure you could create another screen class to set layout
>by force.
>
>Jeff Painter
>painter@kiasoft.com
>
>
>On Tue, 28 Jan 2003, Bruce Altner wrote:
>
> > Greetings:
> >
> > I have a link on a main page that uses javascript to pop up a small window
> > containing another template, popup.vm.
> > The main page uses Default.vm as a layout but this is not appropriate in a
> > small popup window so I have popup.vm call
> > a different layout. Problem is, this overrides the Default layout in 
> main.vm.
> >
> > This surprised me since these are two separate windows but I guess Turbine
> > doesn't care. Is there a way to force Turbine to use
> > different layouts for different windows?
> >
> > Thanks,
> > Bruce
> >
> >
> >
> >
> > --
> > To unsubscribe, 
> e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> >
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>



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


Re: Dueling layouts

Posted by Jeffery Painter <pa...@kiasoft.com>.
I have done this with no problem. I needed to create a 
"PrinterFriendly.vm" and layout which is totally seperate from the regular 
site.

My pop up is called from javascript / velocity generated url

 http://valentinedesigngroup.com - working example

I have a class in project.screens.PrintOut.java that calls 

 data.setLayoutTemplate("/PrinterFriendly.vm");

I did find that you need to make sure your template has a "unique" name... 
if it is called the same as your screen file, then this will cause turbine 
to become confused.

main.vm should call your default template set in your TR.props, but if you 
really want to be sure you could create another screen class to set layout 
by force.

Jeff Painter
painter@kiasoft.com


On Tue, 28 Jan 2003, Bruce Altner wrote:

> Greetings:
> 
> I have a link on a main page that uses javascript to pop up a small window 
> containing another template, popup.vm.
> The main page uses Default.vm as a layout but this is not appropriate in a 
> small popup window so I have popup.vm call
> a different layout. Problem is, this overrides the Default layout in main.vm.
> 
> This surprised me since these are two separate windows but I guess Turbine 
> doesn't care. Is there a way to force Turbine to use
> different layouts for different windows?
> 
> Thanks,
> Bruce
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Dueling layouts

Posted by Bruce Altner <ba...@hq.nasa.gov>.
Greetings:

I have a link on a main page that uses javascript to pop up a small window 
containing another template, popup.vm.
The main page uses Default.vm as a layout but this is not appropriate in a 
small popup window so I have popup.vm call
a different layout. Problem is, this overrides the Default layout in main.vm.

This surprised me since these are two separate windows but I guess Turbine 
doesn't care. Is there a way to force Turbine to use
different layouts for different windows?

Thanks,
Bruce




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>