Re: WOPopUpButton problem...

David LeBer <[email protected]>
Newsgroups gmane.comp.web.webobjects.newbies
Message-ID <[email protected]>
On Dec 7, 2004, at 10:59 PM, jdgazer wrote:

>
>
> Can someone help me with this, im really stuck with it, i know that
> there have been some existing issues with WOPopUpButton, ive tried
> working with but havent got it right, hopefully someone could give me
> a precise guide on this, here is my schema:
>
> two tables (reference tables)
> - userinformation
> ->userid (primary)
> ->username
> ->userpassword
> ->userlevel
> - authenticationlevel
> ->authid (primary)
> ->autdescription (values[admin,supervisor,staff])
>
> So basically the scenario is that a page used to add users, having
> WOPopUpButton displaying user authentication. I had it displayed,
> Unfortunately i cant save it. Here some snippet with my code:
> ----------------------------------------------------------------

You can't save it? What can't you save? What happens?

Also, what are your bindings for the WOPopupButton? Can we see it's 
snippet from the .wod?

> public class Main extends WOComponent {
>
> protected AuthLevel auth;
> protected AuthLevel authItem;
>
> protected UserInfo user;
> protected UserInfo userItem;
>
> /** @TypeInfo AuthLevel */
> protected NSMutableArray authList;
> /** @TypeInfo UserInfo */
> protected NSMutableArray userList;
>
> private EOEditingContext editingContext;
> private EOFetchSpecification fetchSpec;
>
> private EOEditingContext editingContext2;
> private EOFetchSpecification fetchSpec2;
>
> public Main(WOContext context) {
> super(context);
>
> fetchSpec = new EOFetchSpecification
> ("userinformation", null, null);
> editingContext = session().defaultEditingContext();

Why two editing context variables?

You are assigning them to the same context. 
(session().defaultEditingContext())

It is usually considered dangerous to assign this to a variable, I 
usually subclass my components from a common parent that has 
convenience methods like:

public EOEditingContext ec() {
	return session().defaultEditingContext();
}

> authList = new NSMutableArray
> (editingContext.objectsWithFetchSpecification(fetchSpec));
> auth = new AuthLevel();
>
> //======
>
> fetchSpec2 = new EOFetchSpecification
> ("authenticationlevel", null, null);
> editingContext2 = session().defaultEditingContext();
>
> userList = new NSMutableArray
> (editingContext2.objectsWithFetchSpecification(fetchSpec2));
> user = new UserInfo();
>
> }
>
> public WOComponent addUser()
> {
> if(!userList.containsObject(user)){
> userList.addObject(user);
> editingContext2.insertObject(user);
> user = new UserInfo();
> }
> return null;
> }
>
> public WOComponent delUser()
> {
> userList.removeObject(userItem);
> EOEditingContext ec = userItem.editingContext();
> ec.deleteObject(userItem);
> return null;
> }
>
> public WOComponent edtUser()
> {
> user = userItem;
> return null;
> }
>
> public WOComponent updUser()
> {
> user = new UserInfo();
> return null;
> }
>
> public WOComponent revChanges2()
> {
> editingContext2.revert();
> userList = new NSMutableArray
> (editingContext2.objectsWithFetchSpecification(fetchSpec2));
> return null;
> }
>
> public WOComponent savChanges2()
> {
> editingContext2.saveChanges();
> return null;
> }
>
> }
>
>
> ------------------------------------------------------
> Any help would be much appreciated, this is the only thing that holds
> me from my project completion.
>
> Thank you
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>

;david

--
David LeBer
Codebase Software Systems
site:   http://www.codebase.ca
blog: http://david.codebase.ca
smime.p7s (application/pkcs7-signature, 2.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.