[Logo] RSF Discussions Forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Setting up stuff in tables...  XML
Forum Index -> RSF Help and Problems
Author Message
stevegithens
Request-scope Wrangler

Joined: 04/04/2006 20:34:52
Messages: 84
Location: ooeepooee
Offline

Ok, I'm running out of major hurdles, but I'm still grappling with how to bind multiple rows of generated widgets in a table.

Example, I need to create a table to set permissions. Each row will have the role name, and a set of checkboxes, one for each permissions.

On submit I need to run through each and set the permissions. Which need to be fossilized. (I think I'm using that term correct, I need to get the permissions from persistence to populate the form, and then update them on submit).

I've been looking at the hibernate example, since it has the delete buttons in each row, but I think that's different (as UIBoundBoolean doesn't seem to have a parameters attribute).

I'm guessing I need to create a bean which has a List/Vector of something like:

Code:
 class RolePermissions {
 String rolename;
 boolean add;
 boolean read;
 boolean delete;
 boolean revise;
 }
 


But am still unsure how to wire it up to the code in my producer...
Code:
 public void fillComponents(UIContainer arg0, ViewParameters arg1, ComponentChecker arg2) {
 		UIForm form = UIForm.make(arg0, "basic-form");
 		
 		List rolenames = util.getRoleNames();
 		
 		for (Iterator i = rolenames.iterator(); i.hasNext();)
 		{
 			String rolename = (String) i.next();
 			UIBranchContainer b = UIBranchContainer.make(form, "tablerow:");
 			UIOutput.make(b, "rolename", rolename);
 			
 			//How do I bind these?
 			UIBoundBoolean.make(b, "read", util.hasFunc(rolename,"annc.read"));
 			UIBoundBoolean.make(b, "new", util.hasFunc(rolename,"annc.new"));
 			//etc
 		}
 		
 		UICommand c = UICommand.make(form, "save", "#{setAnncPermsAction.setPermissions}");
 		
 		
 	}
 



Suggestions? thx
[WWW]
antranig
Request-scope Wrangler

Joined: 03/04/2006 13:29:55
Messages: 643
Offline

OK... I think you're going to like this one

What you need is basically a bit of OTP. The different rows need to be bound to some EL paths which will cause the "correct thing" to be written - you could either put the List itself into the bean model, e.g. turn your util.getRoleNames() method into a bean constructing a List which sits in the request scope -

<bean id="roleperms" factory-bean="RoleFactory" factory-method="getRoles"/>

You can then access the individual RolePermission objects under the paths #{roleperms.1}, #{roleperms.2} etc. However this is somewhat unreliable since the roles may well be DIFFERENT on the request cycle when the POST has been handled. This is the sort of thing that JSF is often sloppy about since it relies that some random stuff has been "fossilized" into the Session that will not change until the next cycle comes.

So in fact, you'd probably be better off actually making this a Map, so then you would get to the permissions by #{roleperms.access}, #{roleperms.maintain} etc.

However, even more cool/straightforward might be to just make a "true" OTP exploder, simpler than making a Map you can just make it a BeanLocator or WriteableBeanLocator. Looking at the Sakai APIs though (AuthzGroup, Role, etc. I don't see any standard POJO-type entities that you can punch through to directly. In particular the problem is that Role.getAllowedFunctions() returns a Set, which is a bit hard to address via EL...
joshryan
Request-scope Wrangler

Joined: 22/05/2006 05:45:39
Messages: 42
Offline

Sorry this is slightly off topic, but it looks like you've got some cool stuff in the works here, is any of it up any where a guy could take a peek at yet?

In the process of learning RSF I'm starting to play around with the idea of redoing some Sakai stuff (first thought was resources, but it sounds like you've got that covered already). If you don't mind sharing I would love a larger scale example then the current examples.
stevegithens
Request-scope Wrangler

Joined: 04/04/2006 20:34:52
Messages: 84
Location: ooeepooee
Offline

Howdy Josh! I am working on a small gallery of Sakai examples to accompony things in Vancouver... so they should be out soon.

I'm touching a little on resources, but it would be great to have some more influx. One of the great things with RSF is that you can really play around with the GUI to try out new prototypes.

[WWW]
 
Forum Index -> RSF Help and Problems
Message Quick Reply
Go to:   
Powered by JForum 2.1.6 © JForum Team