So do you mean do something like this?
public abstract class CompanyInfo extends BaseComponent {
private boolean dispayLogo = false;
private Company company;
private Users user;
/**
* @return Returns the company.
*/
public Company getCompany(){
return(((CompanyProfile) getPage()).getCompany());
}
/**
* @param company The company to set.
*/
public void setCompany(Company company) {
this.company = company;
}
/**
* @return Returns the user.
*/
public Users getUser(){
return(((CompanyProfile) getPage()).getUser());
}
/**
* @param user The user to set.
*/
public void setUser(Users user) {
this.user = user;
}
}
On Tue, 12 Jul 2005 16:32:37 -0400, "Todd O'Bryan" <[EMAIL PROTECTED]>
said:
> You can only use this component on a page that has getUser() and
> getCompany() defined, right? Create a page superclass that defines
> those two and has the code to get them from the Visit. Then in your
> component you can use ((MyPageSuperClass) getPage()).getUser() and
> similar to get access to them.
>
> You don't really need a separate copy in the component if you can get
> it from the Visit, right?
>
> Todd
>
> On Jul 12, 2005, at 4:23 PM, Java Leech wrote:
>
> > So I guess I don't understand how to initialize these properties for
> > components.
> > If i create a <property-specifications> in my.jwc how do I retrieve
> > the
> > Object I have stored in the Visit()?
> >
> >
> > On Tue, 12 Jul 2005 15:59:22 -0400, "Jamie Orchard-Hays"
> > <[EMAIL PROTECTED]> said:
> >
> >> You need to learn some Tapestry conventions. The first is that when
> >> you have page or component properties, you generally should not
> >> define them in the Java file with instance variables and get/setters.
> >> What you should do is define them in your .page or .jwc file as
> >> <property-specifications>. When you do this, Tapestry will handle the
> >> initialization they need to be cleaned up for page pooling (pages are
> >> pooled for performance).
> >>
> >> When you have a page or component property that needs to be accessed
> >> inside your java file, then you make an abstract getter and/or
> >> setter:
> >> public abstract String getSomeProperty();
> >> public abstract void setSomeProperty();
> >>
> >> Jamie
> >>
> >> On Jul 12, 2005, at 2:50 PM, Java Leech wrote:
> >>
> >>
> >>> Could someone guide me in the right direction here?
> >>> Here is the code for a component that I have:
> >>>
> >>> public class CompanyInfo extends BaseComponent {
> >>> private Users user = new Users();
> >>> private Company company = new Company();
> >>> private boolean dispayLogo = false;
> >>>
> >>>
> >>>
> >>> /**
> >>> * @return Returns the company.
> >>> */
> >>> public Company getCompany() {
> >>> Visit visit = (Visit) getPage().getVisit();
> >>> return (visit.getCurrentCompany());
> >>> }
> >>> /**
> >>> * @param company The company to set.
> >>> */
> >>> public void setCompany(Company company) {
> >>> this.company = company;
> >>> }
> >>> /**
> >>> * @return Returns the user.
> >>> */
> >>> public Users getUser() {
> >>> Visit visit = (Visit) getPage().getVisit();
> >>> Users u = visit.getUsers();
> >>> return u;
> >>> }
> >>> /**
> >>> * @param user The user to set.
> >>> */
> >>> public void setUser(Users user) {
> >>> this.user = user;
> >>> }
> >>> ...../
> >>> }
> >>>
> >>> When I log in with two different browsers on different machines I
> >>> get
> >>> the following exception:
> >>> Unable to resolve expression 'company.name' for
> >>> [EMAIL PROTECTED]
> >>> [CompanyProfile/compInfo].
> >>> binding: ExpressionBinding[CompanyProfile/compInfo company.name]
> >>> location: context:/WEB-INF/CompanyInfo.html, line 12
> >>>
> >>> ognl.OgnlException
> >>> source is null for getProperty(null, "name")
> >>>
> >>> Users() and Company() are my persistant Hibernate Classes. What is
> >>> the
> >>> best way to do this? Basically this component shows information
> >>> about
> >>> the current company that the user belongs to. I have stored the
> >>> Users()
> >>> in the Visit and want to pull up this information.
> >>> Thanks.
> >>> ~chris
> >>>
> >>>
> >>>
> >>> On Tue, 12 Jul 2005 11:00:31 -0500, "Joel Trunick"
> >>> <[EMAIL PROTECTED]> said:
> >>>
> >>>
> >>>>
> >>>> It's caused because the page is cached. It still has the old
> >>>> "Users"
> >>>> object with the values filled in the first time. Something like the
> >>>> following will fix (I personally user a getter with lazy
> >>>> initialization,
> >>>> and initialize users to null):
> >>>>
> >>>> public void initialize() {
> >>>> Users users = new Users();
> >>>> }
> >>>>
> >>>> Joel
> >>>>
> >>>> -----Original Message-----
> >>>> From: Java Leech [mailto:[EMAIL PROTECTED]
> >>>> Sent: Tuesday, July 12, 2005 9:25 AM
> >>>> To: [email protected]
> >>>> Subject: Newbie with Thread Issues
> >>>>
> >>>> I have posted this on the forum but it seems there is not to much
> >>>> action
> >>>> there. So I'll try the mailing list.
> >>>>
> >>>> I'm not sure what I am doing wrong but I seem to be having some
> >>>> serious
> >>>> thread problems. I have been developing an app for about a week and
> >>>> today was the first time I brought up a browser on another machine
> >>>> to my
> >>>> webapp. I knew something was wrong immediatly when my login form
> >>>> was
> >>>> autofilled with the values that I used in the first browser.
> >>>>
> >>>> After trying to log in got a bunch of null value exceptions and
> >>>> can't
> >>>> ever log back in with out restarting jboss. I am using
> >>>> Hibernate3 and
> >>>> Tapestry 3.03 running on jboss.
> >>>>
> >>>> Here is a code snippet from my login component:
> >>>>
> >>>> public abstract class NavLogin extends BaseComponent implements
> >>>> IForm{
> >>>>
> >>>> private ICallback callback;
> >>>> private Users users = new Users();
> >>>>
> >>>> public void setCallback(ICallback callback) {
> >>>> this.callback = callback;
> >>>> }
> >>>>
> >>>> public void formSubmit(IRequestCycle cycle){
> >>>> //Form Validation
> >>>> ValidationDelegate delegate =
> >>>> (ValidationDelegate)getBeans().getBean("delegate");
> >>>>
> >>>> //If no errors add the user
> >>>> if(!delegate.getHasErrors()){
> >>>> System.err.println("Users: "+ getUsers().getEmail() +
> >>>> " Logging in with password: "+
> >>>> HashUtils.md5Sum(getUsers().getPassword()));
> >>>> Users authUser = authenticate();
> >>>> if(authUser != null){
> >>>> Visit visit = (Visit) getPage().getVisit();
> >>>> visit.setUsers(authUser);
> >>>>
> >>>> if(authUser.getRole().getType().equalsIgnoreCase("provider")){
> >>>> cycle.activate("CompanyProfile");
> >>>> }
> >>>> }
> >>>> }
> >>>> }
> >>>> /**
> >>>> * Authenticate the user attempting to log in
> >>>> * @return
> >>>> */
> >>>> public Users authenticate(){
> >>>> UserDAO dao = new UserDAO();
> >>>> Users aUser = dao.authUser(getUsers().getEmail(),
> >>>> HashUtils.md5Sum(getUsers().getPassword()));
> >>>> return(aUser);
> >>>> }
> >>>>
> >>>> --
> >>>> http://www.fastmail.fm - The professional email service
> >>>>
> >>>>
> >>>> -------------------------------------------------------------------
> >>>> --
> >>>> To unsubscribe, e-mail: tapestry-user-
> >>>> [EMAIL PROTECTED]
> >>>> For additional commands, e-mail: tapestry-user-
> >>>> [EMAIL PROTECTED]
> >>>>
> >>>>
> >>>>
> >>>> -------------------------------------------------------------------
> >>>> --
> >>>> To unsubscribe, e-mail: tapestry-user-
> >>>> [EMAIL PROTECTED]
> >>>> For additional commands, e-mail: tapestry-user-
> >>>> [EMAIL PROTECTED]
> >>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> http://www.fastmail.fm - And now for something completely
> >>> different…
> >>>
> >>>
> >>> --------------------------------------------------------------------
> >>> -
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: tapestry-user-
> >>> [EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: tapestry-user-
> >> [EMAIL PROTECTED]
> >>
> >>
> >
> > --
> > http://www.fastmail.fm - Access all of your messages and folders
> > wherever you are
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
http://www.fastmail.fm - Does exactly what it says on the tin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]