You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by David Wynter <da...@btclick.com> on 2001/11/02 14:55:13 UTC

More struggles with TurbineSecurity framework

Hello,

I have posted 4 times previously to this list and only once got a response
and that was a friend I was working on a project with. So I must be doing
something completely off the wall to get no help from the people on the list
who 'know'.

After spending hours trying different methods of saving a User with a Role
and Group I achieved that (my last post). Now I wish to update the Role in
the same screen. I use a pull tool for all entitylist population on screen.
One of the methods is

	/**
	 * Get all role from the turbine table
     */
	public List getAllRoles() throws Exception
	{
        Role[] roles=TurbineSecurity.getAllRoles().getRolesArray();
		return Arrays.asList(roles);
	}

I also tried

	/**
	 * Get all role from the turbine table
     */
	public List getAllRoles() throws Exception
	{
	  Criteria crit = new Criteria();
        Role[] roles=TurbineSecurity.getRoles(crit).getRolesArray();
		return Arrays.asList(roles);
	}

In the template I have:

## Set up entries in the roleType drop-down
#set ( $userRoles = $entitylist.getAllRoles() )
#if (!$selectedRole && ($userRoles.size()>0))
	#set ( $selectedRole=$userRoles.get(0) )
#end

I note that I get this exception when ever I access this template.

     [java] ASTMethod.execute() : exception invoking method 'size' in class
java
.util.Arrays$ArrayList : java.lang.IllegalAccessException

If I put $selectedRole.getName() in the BODY of the HTML it never has a
value displayed. I also tried
putting $userRoles.size() in the BODY of the HTML and it never displays
either. These are the roles I expect to see

+---------+---------------+------------+
| ROLE_ID | ROLE_NAME     | OBJECTDATA |
+---------+---------------+------------+
|       1 | turbine_root  | NULL       |
|     100 | Administrator | NULL       |
|     101 | Message User  | NULL       |
+---------+---------------+------------+

I have no problems with non TurbineSecurity related entities. Any idea about
what is going on here?

Thanks

David Wynter


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


Re: More struggles with TurbineSecurity framework

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"David Wynter" <da...@btclick.com> writes:

> Being fairly new to Java I was a bit unsure about what methods I could use
> with a [] in VTL so that lead me to use a List class.

A [ ] token in VTL markup is turned into an ArrayList.

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


RE: More struggles with TurbineSecurity framework

Posted by David Wynter <da...@btclick.com>.
John,

The #foreach with a List class works fine. The following method of setting
up a default value for a Role where no selection currently exists fixed my
problem. I use this technique all over the place because it is so
convienient.

In my pull tool

	public List getAllRoles() throws Exception
	{
		Criteria crit = new Criteria();
        	List
roles=org.apache.turbine.om.security.peer.RolePeer.doSelect(crit);
		return roles;
	}

Then in my template I have:

## Set up entries in the roleType drop-down
#set ( $userRoles = $entitylist.getAllRoles() )
#if (!$selectedRole && ($userRoles.size()>0) )
	#set ( $selectedRole=$userRoles.get(0) )
#end

So if $selectedRole exists in the Context from a previous look at this
screen all is fine, if I have not been to the screen before then it selects
a value for me. I also use the $userRoles in a #foreach to populate a
'select' on the same screen, thus:

			#rwLabelCell ("Role")
			<td width="$ui.screenWidgetWidth" >
				<select name="selectedRoleType">
					#foreach ($role in $userRoles)
						#if ($role.getName() == $selectedRole.getName())
							<option selected>$!role.getName()</option>
						#else
							<option>$!role.getName()</option>
						#end
					#end
				</select>
			</td>

Being fairly new to Java I was a bit unsure about what methods I could use
with a [] in VTL so that lead me to use a List class.

David



-----Original Message-----
From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
Sent: 02 November 2001 16:48
To: Turbine Users List
Subject: Re: More struggles with TurbineSecurity framework


Try creating the List as an ArrayList and copying the elements into it
using a loop.  I assume this will work as you say you are not having
problems with other List types.

Also does a #foreach using the List created by Arrays.asList work?  I am
using this function and have not noticed a problem, but off the top of
my head i do not know that i ever call size() from a template on the
resulting list.

If the problem appears to be in the object created by Arrays.asList, I
would mention it on the velocity list.  Not sure whether this would be a
problem with velocity, but it could save some other users the trouble of
getting the same error.

john mcnally

David Wynter wrote:
>
> Hello,
>
> I have posted 4 times previously to this list and only once got a response
> and that was a friend I was working on a project with. So I must be doing
> something completely off the wall to get no help from the people on the
list
> who 'know'.
>
> After spending hours trying different methods of saving a User with a Role
> and Group I achieved that (my last post). Now I wish to update the Role in
> the same screen. I use a pull tool for all entitylist population on
screen.
> One of the methods is
>
>         /**
>          * Get all role from the turbine table
>      */
>         public List getAllRoles() throws Exception
>         {
>         Role[] roles=TurbineSecurity.getAllRoles().getRolesArray();
>                 return Arrays.asList(roles);
>         }
>
> I also tried
>
>         /**
>          * Get all role from the turbine table
>      */
>         public List getAllRoles() throws Exception
>         {
>           Criteria crit = new Criteria();
>         Role[] roles=TurbineSecurity.getRoles(crit).getRolesArray();
>                 return Arrays.asList(roles);
>         }
>
> In the template I have:
>
> ## Set up entries in the roleType drop-down
> #set ( $userRoles = $entitylist.getAllRoles() )
> #if (!$selectedRole && ($userRoles.size()>0))
>         #set ( $selectedRole=$userRoles.get(0) )
> #end
>
> I note that I get this exception when ever I access this template.
>
>      [java] ASTMethod.execute() : exception invoking method 'size' in
class
> java
> .util.Arrays$ArrayList : java.lang.IllegalAccessException
>
> If I put $selectedRole.getName() in the BODY of the HTML it never has a
> value displayed. I also tried
> putting $userRoles.size() in the BODY of the HTML and it never displays
> either. These are the roles I expect to see
>
> +---------+---------------+------------+
> | ROLE_ID | ROLE_NAME     | OBJECTDATA |
> +---------+---------------+------------+
> |       1 | turbine_root  | NULL       |
> |     100 | Administrator | NULL       |
> |     101 | Message User  | NULL       |
> +---------+---------------+------------+
>
> I have no problems with non TurbineSecurity related entities. Any idea
about
> what is going on here?
>
> Thanks
>
> David Wynter
>
> --
> 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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: More struggles with TurbineSecurity framework

Posted by John McNally <jm...@collab.net>.
Try creating the List as an ArrayList and copying the elements into it
using a loop.  I assume this will work as you say you are not having
problems with other List types.

Also does a #foreach using the List created by Arrays.asList work?  I am
using this function and have not noticed a problem, but off the top of
my head i do not know that i ever call size() from a template on the
resulting list.

If the problem appears to be in the object created by Arrays.asList, I
would mention it on the velocity list.  Not sure whether this would be a
problem with velocity, but it could save some other users the trouble of
getting the same error.

john mcnally

David Wynter wrote:
> 
> Hello,
> 
> I have posted 4 times previously to this list and only once got a response
> and that was a friend I was working on a project with. So I must be doing
> something completely off the wall to get no help from the people on the list
> who 'know'.
> 
> After spending hours trying different methods of saving a User with a Role
> and Group I achieved that (my last post). Now I wish to update the Role in
> the same screen. I use a pull tool for all entitylist population on screen.
> One of the methods is
> 
>         /**
>          * Get all role from the turbine table
>      */
>         public List getAllRoles() throws Exception
>         {
>         Role[] roles=TurbineSecurity.getAllRoles().getRolesArray();
>                 return Arrays.asList(roles);
>         }
> 
> I also tried
> 
>         /**
>          * Get all role from the turbine table
>      */
>         public List getAllRoles() throws Exception
>         {
>           Criteria crit = new Criteria();
>         Role[] roles=TurbineSecurity.getRoles(crit).getRolesArray();
>                 return Arrays.asList(roles);
>         }
> 
> In the template I have:
> 
> ## Set up entries in the roleType drop-down
> #set ( $userRoles = $entitylist.getAllRoles() )
> #if (!$selectedRole && ($userRoles.size()>0))
>         #set ( $selectedRole=$userRoles.get(0) )
> #end
> 
> I note that I get this exception when ever I access this template.
> 
>      [java] ASTMethod.execute() : exception invoking method 'size' in class
> java
> .util.Arrays$ArrayList : java.lang.IllegalAccessException
> 
> If I put $selectedRole.getName() in the BODY of the HTML it never has a
> value displayed. I also tried
> putting $userRoles.size() in the BODY of the HTML and it never displays
> either. These are the roles I expect to see
> 
> +---------+---------------+------------+
> | ROLE_ID | ROLE_NAME     | OBJECTDATA |
> +---------+---------------+------------+
> |       1 | turbine_root  | NULL       |
> |     100 | Administrator | NULL       |
> |     101 | Message User  | NULL       |
> +---------+---------------+------------+
> 
> I have no problems with non TurbineSecurity related entities. Any idea about
> what is going on here?
> 
> Thanks
> 
> David Wynter
> 
> --
> 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: More struggles with TurbineSecurity framework

Posted by David Wynter <da...@btclick.com>.
Jason,

I did look at the example, FluxRoleList.* in particular. The only thing I am
doing different to you is I have setup a couple of fixed roles (i only need
2) in a service run at startup and my pull tool actual returns a List class
not a Role[]. I am new to Java so it may be my misunderstanding on how an
array converts to a List ala-

        Role[] roles=TurbineSecurity.getRoles(crit).getRolesArray();
		return Arrays.asList(roles);

I use a List to load all other non TurbineSecurity objects into and all is
fine. I have printed roles[0].getName to the log so I know it is being
retrieved.

I am still at a loss to explain why this does not work. I'd use Role[] if I
could work out how to select a default selected role if none was previuosly
selected in VTL.

Thanks

David

-----Original Message-----
From: Jason van Zyl [mailto:jvanzyl@zenplex.com]
Sent: 02 November 2001 13:58
To: Turbine Users List
Subject: Re: More struggles with TurbineSecurity framework


On 11/2/01 8:55 AM, "David Wynter" <da...@btclick.com> wrote:

> Hello,
>
> I have posted 4 times previously to this list and only once got a response
> and that was a friend I was working on a project with. So I must be doing
> something completely off the wall to get no help from the people on the
list
> who 'know'.

Look at the fully working flux example.



--

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
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: More struggles with TurbineSecurity framework

Posted by Jason van Zyl <jv...@zenplex.com>.
On 11/2/01 8:55 AM, "David Wynter" <da...@btclick.com> wrote:

> Hello,
> 
> I have posted 4 times previously to this list and only once got a response
> and that was a friend I was working on a project with. So I must be doing
> something completely off the wall to get no help from the people on the list
> who 'know'.

Look at the fully working flux example.

 

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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