aspose file tools*
The moose likes Groovy and the fly likes acegi security plugin, Person and one of my domain objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "acegi security plugin, Person and one of my domain objects" Watch "acegi security plugin, Person and one of my domain objects" New topic
Author

acegi security plugin, Person and one of my domain objects

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

So, I want to tie in a User/Person to a domain object I have called Band. The thing is a user can have/create only one Band. So the whole List and Create links in the BandController is not needed.

So I am a bit not sure of my best solution.

I was thinking I could just put the attributes that I had in the Band object and just put it in the Person object, since I can think of them as one in the same.

Or I could make a one to one association in the Person object to the Band object. But I think I would have to customize the BandController.

If I include the attributes in the Person, then I can remove the Band object and the Band Controller etc.

Has anyone done something like this? What was your solution?

Did I make sense in my situation?

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Technically, I wouldn't consider a person and a band to be the same thing, so I wouldn't put band attributes in person. If one person can belong to only one band then I'd just have a one-to-one. I'd also consider cascading. I person should "belongTo" a band, right? In the real world, however, a person can be in multiple bands, but I assume you're model is specific to your needs.

As far as customizing BandController, I'm not sure what you mean. All my controllers are customized except the very basic bare bones domains that require very simple CRUD and aren't public facing at all. Which is rare. Most folks come into Grails thinking that you shouldn't need to modify a controller and view very much. That scaffolding and CRUD is enough, or should be enough. I know that's what I thought, but really, the best part of grails is NOT scaffolding, nor is it really the web layer at all, IMHO. I generate controllers for quick mock ups and proof of concepts. Then I go and move most of my controller to code to services, so they are transactional (when they need to be). My controllers stay lean and mean.

For me though, Grails is all about GORM baby! GORM makes grails what it is. Well, GORM and Groovy, but you can't have one without the other.


GenRocket - Experts at Building Test Data
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

What about the gsp pages? Do you stick with them? Although I did notice <table> tr, td tags which I don't like. Well, to be honest, I don't like any html. ;)

But I heard that using tables for layout is old old school now.

Yeah the GORM is really cool, and makes so much sense and I like it better than how I love Hibernate annotations in my domain classes.

Luckily, most of what my app is is basic Crud for the user. They will need to put lots of data in. I still will need to customize it to make it pretty and also for the assocations for parent-child stuff. Any plugin for that to make it easier?

Also, there is definitely one to one with person band and to me in my domain they are one and the same.

By the way, you are part of my project, I will need your help using Groovy to generate some Objective-C and other iPhone app related stuff. ;)

Let me PM you.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Mark Spritzler wrote:What about the gsp pages? Do you stick with them? Although I did notice <table> tr, td tags which I don't like. Well, to be honest, I don't like any html. ;)

But I heard that using tables for layout is old old school now.

Mark


It really depends on what needs to be done. Sometimes I take the GSP and just modify it. Sometimes, I create the GSP from scratch. For one particular app I am building there is zero generated code. Grails scaffolding uses tables for tabular data and forms. It's main.gsp (layout) doesn't have tables for header/body/footer. It is just DIV elements.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

If I keep Band and Person separate, even with a One To One relationship, for entering data into other objects and such, should I create a Filter so that they only see their band data, or some other means?

Thanks

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Mark Spritzler wrote:If I keep Band and Person separate, even with a One To One relationship, for entering data into other objects and such, should I create a Filter so that they only see their band data, or some other means?

Thanks

Mark


I'm not sure why you would need a filter. If you don't want them modifying/seeing specific data, don't put that data in your views.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Unfortunately, I don't thing the acegi plugin worked well when I changed Person to be my Band. I now have a registrationController and a bandController and each are a bit different. For instance, the BandController does no encrypting like the RegistrationController does, and now I am confused at when a page should use which controller.

I get the registration link and enter in data, but then I go to the login page and it won't login as the Band I just created.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Did you update the SpringSecurity.config file so it knows Band is your person object? Also, you should be able to copy the original Person controller code directly to the band controller. Or you can just re-run the scripts 'generate-manager', etc.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Gregg Bolinger wrote:Did you update the SpringSecurity.config file so it knows Band is your person object? Also, you should be able to copy the original Person controller code directly to the band controller. Or you can just re-run the scripts 'generate-manager', etc.


Yeah, I changed it all before. I got it all working.

Although, now my Captcha doesn't work the first time your register.

I type in what the captcha shows and it comes back with the error message that it didn't match and you get a new captcha. you enter the new value, and retype in your passwords again, then it works.

Basically this is returning true, when it shouldn't the first time through.

if (params.captcha.toUpperCase() != session.captcha) {

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Getting the Domain classes CRUD pages into the Sitemesh Layout.

So how do I get those list, edit etc pages into the main Sitemesh Layout.

Basically those gsp pages are already using the SiteMesh layout for the page itself, so I can't see how to get it in the layout again. Basically I want the page to be the body while still being in its own layout.

Does that make sense.

The CRUD pages already have

<meta name="layout" content="main" />

I think I know the basic problem, is the page I really want those CRUD pages to be the Body for is the index.gsp page in the root of the views directory.

They should have been doing this automatically in the first place.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Mark Spritzler wrote:Does that make sense.


No.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Are you saying you just want the root index.gsp to show something different?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Gregg Bolinger wrote:Are you saying you just want the root index.gsp to show something different?


I want the List of News, and edit News, and create News to be in the body section, not take the entire page which removes the header/left nav that you see from the index page.

so the main layout is the main layout, with another main layout in the body of the first main layout. So the CRUD pages looks to stay in the main page, but in the body section.

I guess I could put the stuff that is in the index into the main layout gsp page, then all the others that use the main layout will have the header and left nav always there.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Mark Spritzler wrote:
Gregg Bolinger wrote:Are you saying you just want the root index.gsp to show something different?


I want the List of News, and edit News, and create News to be in the body section, not take the entire page which removes the header/left nav that you see from the index page.

so the main layout is the main layout, with another main layout in the body of the first main layout. So the CRUD pages looks to stay in the main page, but in the body section.

I guess I could put the stuff that is in the index into the main layout gsp page, then all the others that use the main layout will have the header and left nav always there.

Mark


Ah, I see. That junk you see in index.gsp is something I generally move to a protected page accessed via a secure controller. It's not something you want all your general users seeing. But if you really want that, then as you said, you'll need to move that into your layout/main.gsp. There might be a way to nest layouts but I haven't had a need so haven't looked that deeply into customizing sitemesh beyond the basics.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Gregg Bolinger wrote:
Mark Spritzler wrote:
Gregg Bolinger wrote:Are you saying you just want the root index.gsp to show something different?


I want the List of News, and edit News, and create News to be in the body section, not take the entire page which removes the header/left nav that you see from the index page.

so the main layout is the main layout, with another main layout in the body of the first main layout. So the CRUD pages looks to stay in the main page, but in the body section.

I guess I could put the stuff that is in the index into the main layout gsp page, then all the others that use the main layout will have the header and left nav always there.

Mark


Ah, I see. That junk you see in index.gsp is something I generally move to a protected page accessed via a secure controller. It's not something you want all your general users seeing. But if you really want that, then as you said, you'll need to move that into your layout/main.gsp. There might be a way to nest layouts but I haven't had a need so haven't looked that deeply into customizing sitemesh beyond the basics.


Really, I thought the index page is the main public page. That way that is the starting point for users and non-users. Users can hit the login, and non-users can hit the register link.

Yeah, I need some type of layout/template at work, kind of like what I had used before with .xhtml and while I dislike Tiles, like Tiles.

I am sure SiteMesh provides a mean to do this.

Going to check some documentation. I hate reading docs. ;)

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, yea, you can use the index page as your entry point. Most times I create a HomeController with an index page and then simply have the root index redirect me. I always like to hit a controller first and by using the root index.gsp, you aren't really doing that. By move, I meant copy. I still have my root indexgsp. It's just simply a redirect.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Gregg Bolinger wrote:Well, yea, you can use the index page as your entry point. Most times I create a HomeController with an index page and then simply have the root index redirect me. I always like to hit a controller first and by using the root index.gsp, you aren't really doing that. By move, I meant copy. I still have my root indexgsp. It's just simply a redirect.


Ah, yeah, I don't think there is a need for my app to have to call a Controller first.

But I have managed to move the left nav menu into the main.gsp layout and using template gsp files.

Now, I am just having some css issue. I got my CRUD stuff showing in the "body" to the right of the left nav menu. But the buttons/links at the top or bottom of those CRUD pages are taking up the entire screen from left to right, so they end up in part of the left nav menu.

I managed to give up with the top part, I even added a fake "button" bar on the top of the index/home page. I just can't get the bottom to be more to the right. I thought I figured out the right css class to change, but everything I tried to move it more to the right failed miserably.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, just don't try and blame grails on your lack of CSS skillz.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Gregg Bolinger wrote:Well, just don't try and blame grails on your lack of CSS skillz.


I am not, I understand how to read some of it. However, there are certain things that just aren't making sense to me.

So in a list view, how does the table know who big to make a column for a field. I have two String variables in a domain object.
Neither have size constraints, yet one column is wider than the other. And the thing is, the different is correct. Meaning one would have a little more information
in it.

There are no css classes for each column.

Also, I have a weird thing where the bottom button row of one create page takes the entire width, from far left to far right, then I have another that correctly puts it about 150px in from the left to line up nicely with the form.

I look at both pages and except for specific fields, they are identical. I just can't figure out why one works the way I want it to, lined up with the form, and the others don't

I mean I tried to find anything that was different and it was just specific fields.

Thanks

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: acegi security plugin, Person and one of my domain objects