Article

wschreiber's picture
article
Reads:

3514

Score:
0
0
 
Comments:

0

Getting an eDirectory Object from a Property Book Page

Author Info

13 February 2008 - 8:13am
Submitted by: wschreiber

(View Disclaimer)

Problem

A Forum reader recently asked:

"I'd like to access the eDirectory object I'm currently modifying in iManager as a com.novell.admin.ns.NSObject from the JSP file. How do I get this object?

<%
NSObject iam = ???
%>

I'm talking about a property book page. I do not want to change any values in eDirectory; I just want to do some
simple parsing on existing values."

And here is the response from Wolfgang Schreiber ...

Solution

To get your handle on the selected object(s) in the JSP code of a property book page, you may add code similar to this into your JSP:

  <%
    // get handles into tree ... please add error handling
    TaskContext           taskContext           = 
eMFrameFactory.getTaskContext( request );
    AuthenticationBroker  authenticationBroker  = 
taskContext.getAuthenticationBroker();
    ObjectEntry           oeTree                = (ObjectEntry) 
authenticationBroker.getAPIObject( "NDSNamespace" );
    NDSNamespace          ns                    = ( NDSNamespace ) 
oeTree.getNamespace();

    // get the selected target(s)
    String    sTargetsPacked  = (String) request.getAttribute( 
"eDir$target" );
    String[]  saTargets       = eMFrameUtils.unpack( sTargetsPacked, 
taskContext );
    // prepare display
    String    sDisplay        = "Objects selected: " + String.valueOf( 
saTargets.length ) + "<br>";
    for ( int i=0; i<saTargets.length; i++ )
    {
      ObjectEntry  oeTarget   = oeTree.getNamespace().getObjectEntry( 
saTargets[i] );
      NSObject     nsoTarget  = ns.getDetails( oeTarget );
          sDisplay += saTargets[i] + " (" + oeTarget.getFullName() + 
")<br>";
    }
  %>

  <TR VALIGN="TOP">
     <TD align=left>Targets (packed): &nbsp</TD>
     <TD><%= sTargetsPacked %></TD>
  </TR>
  <TR><TD height="8"></TD></TR>

  <TR VALIGN="TOP">
     <TD align=left>Targets (unpacked):  </TD>
     <TD><%= sDisplay %></TD>
  </TR>
  <TR><TD height="8"></TD></TR>

Do not forget to add the proper import statements to the JSP header. For example:

<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" 
import="com.novell.emframe.dev.*,com.novell.application.console.snapin.*,com.novell.admin.ns.*,com.novell.admin.ns.nds.*" 
%>


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.




User Comments

© 2013 Novell