To logoff using code in BSP

Hi,
   I have a requirement wherein based on some conditions coded in BSP, I want to do either of the following:
1. Logoff from portal with a message, say "Wrong mapping".
2. Call USER MAPPING in PERSONALISE option.
  Kindly suggest me the way to do both the things by writing the code in BSP.
Regards,
Santosh

HI Santosh,
Portal Applications,like ITS-based applications and BSP ,are rendered in their own IFRAME ,and do not have control over the PARENT window.Using the BSP logoff application page,you won't be able to logoff from the Portal,but the reverse is possible,like based on some events like Personalize Portal or LOGOFF from portal,we can follow up in our BSP application.
The Enterprise Portal Client Framework (EPCF) provides an infrastructure for scripting used in iViews and by the Portal.
Using EPCM.subscribeEvent( nameSpace, eventName, eventHandler ) ,we can subscribe to portal events and act acordingly
while using EPCM.raiseEvent( nameSpace, eventName, dataObject [, sourceId]),we can raise an event.
I have tried the first case,where if user presses the personalise option or logs off from portal,we can do something,like show an alert.
But in the other way,when i tried to raise an event to logoff from portal,the event was generated,as i could perceive,as it was caught by the subscribe event to portal logoff,but it doesn't  actually "logoff" the portal.
I guess it is for  Security reasons that we get access denied trying to access and use Scripts on Portal Objects directly.
Using the SYSTEM application logoff would'nt work in any case as it would try to logoff from the WAS on which BSP is hosted whereas the session is maintained and stored by the Portal.
HOpe this helps,
Regards,
Siddhartha
Hope this helps,

Similar Messages

  • Questions on using classes inside BSP pages

    Hi Group,
    I have a few questions on how to use classes,interfaces,parameters in classes,
    and etc., relating to OOPs concepts that can be implemented in BSPs.
    Pls send me some link wherein I can explore things and use it in BSPs.
    Thanks & Regards,
    Vishnu.

    Hi Raja,
    I am facing issues like this:
    1) When I use the code in my BSP as under:
    <%
    class ZCL_MODEL_03 definition load.
    data ref1 type ref to ZCL_MODEL_03.
    data cust_id type c value "1000".
    data c_id type c.
    create object ref1.
    c_id = cust_id.
    call method ref1->CHECK_CUSTOMER changing cid = cust_id.
    %>
    Cannot we define variables in the Scriptlet?? or we need to do only in the attributes sections only?? or in both??
    2)I am not able to use both exporting & importing things in my method call.
    eg.,call method ref1->GET_CUSTOMER
                      exporting cid = cust_id
                      importing c_id = eid.
    In the method definition, I am only using simply logic like, I was trying to send a value into the "cid" defined in the method and putting that value into "eid" which was defined exporting, but, still I could not get the value into "c_id" that I have defined in the BSP page.
    Note: in both the things(in BSP and class definition as well, I am using the same
            type for defining the attributes.
    3)When can we define a "Returning" option in the Class method's parameter    
       Definition? and how can I use it with an example?
    Thanks in advance.
    Regards,
    Vishnu.

  • How to use GUI_DOWNLOAD inside BSP Application event

    Hi All,
    I am facing one issue while using GUI_DOWNLOAD inside BSP Application. When the processing goes at GUI_DOWNLOAD it gives me unknown error where as the same code is working when used in report program. My requirement is to save password into excel file at my local machine. I am using FM MS_EXCEL_OLE_STANDARD_DAT to save password in excel file but this function module fail when it reach at GUI_DOWNLOAD . Can you please help me out.
    Thanks and Regards
    Pradeep Kr. Rai

    Dear Pradeep,
    Find the below link which explains a simple data download to excel from a table view.
    www.sapt echnical.com/Tutorials/BSP/Excel/Index.htm
    Try to avoid the way your using in the BSP application and it is abdicable to use the standard methods / class available like "cl_bsp_utility"
    Hope this will be helpful.
    Regards,
    Gokul.N
    Edited by: Gokul on Oct 8, 2009 9:57 AM

  • How do I seperate code in BSP ?

    Hi,
    How do I seperate code in BSP ?
    (I do not want to make classes or "external" FM.)
    In abap I can use the form-statement.
    form ShowConfirmedPO.
    endform
    //Martin

    Hi Martin,
    I am a little bit curious. Why you don't want to create any classes/FMs? Believe me if you want to write complex bsp applications which are easily maintainable, extendable and have a good testability you should always use MVC and MVC needs classes. You have all the cool tools available use them
    And regarding your question I don't think there is another way to structure your code when you don't want to use classes.
    regards
    Thomas

  • ABAP Code to BSP Conversion

    Hi ,
    I have Several Programs Created in
    ABAP (with Associated TCodes)which i am calling in Portal Using SAP Transation iView.
    Now i want to convert them in to BSP.
    Instead of Rewriting the Code , Is there
    any Tool , Program ,TCode available
    which will Convert the Existing Code
    to BSP ?
    i am on NW2004s ECC6 .
    Regards
    Rajendra

    NO, there is no such tool.
    if you dont worry about the look and feel and you want HTML view in portal for SAP Transation iView use SAPGUI for HTML option instead of WIGUI while creating the iview.
    Raja

  • How to find u0091Where used list of BSP Applicationu0092?

    Hi,
    In standard, one BSP application is calling another BSP application by hard coded in application.
    I want find a where used list of a BSP application.
    How to find ‘Where used list of BSP Application’?
    Regards,
    ...Naddy

    Hi Naddy,
    there is a way to find such hard coded things as long as they are really written as literal in the coding. So far i havn't used it on BSP but it's just a token search.
    You can use the code inspector for such things (TCode SCI). You define an object list. Therefore you have to use the static list (dynamic won't work) e.g. for all objects in a package. The ugly thing is that sap has built a filter in SCI that you cannot run it on their standard objects (no comment on that). So you get always 0 objects on sap packages. But you can debug into SCI and set a break point on statement 'SELECT'. One of the selects gets the objects from repository. In this statement sap hands select options to exclude SAP objects. If you change the values you can get these objects in the list.
    Then you run a search on these objects to find the string you look for.
    Ok that's not very comfortable but still faster than checking dozens of objects by hand.
    Best regards
    Roman

  • Structures used in PM - BSP

    Hi,
        There is a structure used in HAP_DOCUMENT BSP  'HAP_T_BODY_COLUMNS'. The field of this structure are getting loaded dynamically. One of the field is 'AVAILABILITY'
        In my scenario the 'AVAILABILITY' field is 'X' i want to change this to blank how do i do it. Kindly help.
    Regards,
    Bharath Mohan B.

    Hi,
    Try this code...
    data ls_hap_body_columns type HAP_S_BODY_COLUMNS.
    loop at HAP_T_BODY_COLUMNS into ls_hap_body_columns.
    endloop.
    clear ls_hap_body_columns-AVAILABILITY.
    then move this <b>ls_hap_body_columns</b> structure, as per your needs.
    I hope this will help you.
    Regards,
    Ramki.

  • Java code with BSP

    Hi Experts,
    Is there any way to write java code in BSP pages or to call java code from BSP pages?
    Thanks in Advance
    Shilpa Dhawan

    Hi,
    Let there be no misunderstanding.
    Java has NOTHING to do with Javascript and vice versa.
    Check this like
    http://www.htmlgoodies.com/beyond/javascript/article.php/3470971
    http://www.dannyg.com/ref/javavsjavascript.html
    for the differences
    Eddy
    PS. Reward the useful answers and you will get <a href="/people/baris.buyuktanir2/blog/2007/04/04/point-for-points-reward-yourself">one point</a> yourself!

  • Database connection using code in IDE

    Anybody there please help me. I cannot connect to my database from within the Java Sun One Studio 5 IDE. This situation also happens in the Enterprise Edition; I cannot connect to the oracle database from within the IDE using code.
    Please can someone tell me what I am doing wrong. I have copied all the .jar files in the Oracle 8i Jar/lib folder into the c:\sun\studio5u1_se\lib\ext. I have equally included classes12.zip and classes111.zip into this same location: c:\sun\studio5u1_se\lib\ext
    Also I have mounted this folder c:\sun\studio5u1_se\lib\ext containing all the relevant files (to the best of my knowledge) in the IDE under the filesystem.
    When I compile from the IDE, it compiles fine without errors; also when I build, it builds the code without any problem. But when I execute the code, it throws the error: Driver Not Found: oracle.jdbc.driver.OracleDriver
    Please, can somebody help me, and tell me if there is something I am not doing well.
    I include here the code:
    * displayDepartment.java
    * Created on April 4, 2004, 11:23 PM
    * @author  macdonald
    // Java core packages
        import java.awt.*;
        import java.sql.*;
        import java.util.*;
        import java.lang.*;
       // Java extension packages
       import javax.swing.*;
    public class displayDepartment extends JFrame{
                // Create a connection to the database
            String serverName = "localhost";
            String portNumber = "1521";
            String sid = "istech";
            String url = "jdbc:oracle:thin:@" + serverName + ":" +
                portNumber + ":" + sid;
            String username = "macd";
            String password = "uchenna";
            String strDr;
        /** Creates a new instance of displayDepartment */
    // constructor connects to database, queries  database,
          // processes results and displays results in window
        public displayDepartment() {
            super("Departments");
            // connect to database istech and query database
            try {
                // load database driver class
       Class.forName("oracle.jdbc.driver.OracleDriver");
                // connect to database
            // Create connection from URL
               Connection conn = DriverManager.getConnection(url, username, password);
                // create Statement to query database
             Statement statement = conn.createStatement();
                // query database
               ResultSet resultSet =
                   statement.executeQuery( "SELECT * FROM DEPARTMENTS" );
                // process query results
                StringBuffer results = new StringBuffer();
                ResultSetMetaData metaData = resultSet.getMetaData();
                int numberOfColumns = metaData.getColumnCount();
                for ( int i = 1; i <= numberOfColumns; i++ ) {
                   results.append( metaData.getColumnName( i )
                     + "\t" );
                results.append( "\n" );
                while ( resultSet.next() ) {
                  for ( int i = 1; i <= numberOfColumns; i++ ) {
                      results.append( resultSet.getObject( i )
                         + "\t" );
                  // results += "\n";
                // close statement and connection
                statement.close();
                conn.close();           
                // set up GUI and display window
                JTextArea textArea = new JTextArea(
                   results.toString() );
                Container container = getContentPane();
                 container.add( new JScrollPane( textArea ) );
                setSize( 300, 100 );  // set window size
                setVisible( true );   // display window
             }  // end try
             // detect problems interacting with the database
             catch ( SQLException sqlException ) {
                JOptionPane.showMessageDialog( null,
                   sqlException.getMessage() + strDr, "Database Error",
                   JOptionPane.ERROR_MESSAGE );
                System.exit( 1 );
             // detect problems loading database driver
             catch ( ClassNotFoundException classNotFound ) {
                JOptionPane.showMessageDialog( null,
                   classNotFound.getMessage(), "Driver Not Found",
                   JOptionPane.ERROR_MESSAGE );
                   System.exit( 1 );
          // launch the application
          public static void main( String args[] )
             displayDepartment window = new displayDepartment();
            window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );   
      }  // end class displayDepartment

    the problem is that the oracle jars are not in your execution classpath...higlight the file you are executing or go to tools-> option and in any case select the exection types -> external executer...in the advance tab you can add the jars to the "classpath" setting

  • Useful Code of the Day:  Hideable Tree Nodes

    Someone posted about how they could selectively hide tree nodes, and I already had this AbstractTreeModel class (which does some things DefaultTreeModel does and some it doesn't) and a concrete subclass for TreeNode objects, so I was thinking how one could do hideable nodes. So I came up with this solution.
    There's 4 classes here:
    - AbstractTreeModel is the base for the concrete TreeNodeTreeModel
    - TreeNodeTreeModel extends AbstractTreeModel to support TreeNodes (DefautlMutableTreeNode, etc.)
    - HideableMutableTreeNode which is a DefautlMutableTreeNode subclass which has a visible field (with is/set methods, of course).
    - HideableTreeModel is the hideable model which is a subclass of TreeNodeTreeModel.
    A HideableMutableTreeNode can be set invisible directly, but the tree still needs to be notified to update. So it's best to use the methods in HideableTreeModel which set a node's visibility which notify the tree of changes accordingly. Methods are also provided to check a full path's visibility or ensure a node including all parent nodes are visible.
    A HideableTreeModel can take any TreeNode class, it doesn't have to be all HideableMutableTreeNodes, but only HideableMutableTreeNodes can be made invisible, of course. Any other TreeNode type would just be considered visible.
    Hiding nodes works basically by making the tree think there's less nodes then there are. And to do this, the node counts and child index search just works by looping thru the parent's children. This has potential perfomance drawbacks of course, since one has to loop thru the node's children to get nodes every time. This could be alleviated by not supporting non-hideable nodes changing the internal maintenance of HideableMutableTreeNode contents. But I'll leave that to whoever really needs it. It shouldn't be a problem if there are are a relatively small set of child nodes in any given parent.
    Also, note that the root node in the model cannot be made invisible, cuz it'd be redundant since JTree can be set to hide the root node.
    // *** HideableTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>HideableTreeModel</code> is an <code>TreeNodeTreeModel</code>
    * implementation for <code>HideableMutableTreeNode</code> objects.  The
    * model can also take any other <code>javax.swing.tree.TreeNode</code>
    * objects. 
    public class HideableTreeModel extends TreeNodeTreeModel {
          * Creates a new <code>HideableTreeModel</code> object.
          * @param  root  the root node
         public HideableTreeModel(TreeNode root) {
              super(root);
          * Checks if the specified node is visible.  A node can only be
          * hidden if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this only test the visibility of the specified node, not
          * whether a parent node is visible.  Use <code>isPathToNodeVisible(Object)</code>
          * to check if the full path is visible. 
          * @param  node  the node
          * @param  true if the node is visible, else false
         public boolean isNodeVisible(Object node) {
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        return ((HideableMutableTreeNode)node).isVisible();
              return true;
          * Sets the specified node to be hidden.  A node can only be made hidden
          * if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility.  <br />
          * <br />
          * Note that this will not alter the visibility of any nodes in the
          * specified node's path to the root node.  Use
          * <code>ensurePathToNodeVisible(Object)</code> instead to make sure the
          * full path down to that node is visible.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility. 
          * @param  node  the node
          * @param  v     true for visible, false for hidden
          * @param  true if the node's visibility could actually change, else false
         public boolean setNodeVisible(Object node, boolean v) {
              // can't hide root
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        HideableMutableTreeNode n = (HideableMutableTreeNode)node;
                        // don't fix what ain't broke...
                        if(v != n.isVisible()) {
                             TreeNode parent = n.getParent();
                             if(v) {
                                  // need to get index after showing...
                                  n.setVisible(v);
                                  int index = getIndexOfChild(parent, n);
                                  super.nodeInserted(parent, n, index);
                             } else {
                                  // need to get index before hiding...
                                  int index = getIndexOfChild(parent, n);
                                  n.setVisible(v);
                                  super.nodeRemoved(parent, n, index);
                        return true;
              return false;
          * Checks if the specified node is visible and all nodes above it are
          * visible. 
          * @param  node  the node
          * @param  true if the path is visible, else false
         public boolean isPathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   if(!isNodeVisible(path)) {
                        return false;
              return true;
         * Sets the specified node and all nodes above it to be visible.
         * Note that this method will notify the tree to reflect any changes to
         * node visibility.
         * @param node the node
         public void ensurePathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   setNodeVisible(path[i], true);
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0, j = -1; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             j++;
                        if(j == index) {
                             return pc;
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              int count = 0;
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             count++;
              return count;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              int index = -1;
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   TreeNode c = (TreeNode)child;
                   if(isNodeVisible(c)) {
                        index = 0;
                        for(int i = 0; i < p.getChildCount(); i++) {
                             TreeNode pc = (TreeNode)p.getChildAt(i);
                             if(pc.equals(c)) {
                                  return index;
                             if(isNodeVisible(pc)) {
                                  index++;
              return index;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              HideableMutableTreeNode root = new HideableMutableTreeNode("root");
              root.add(new HideableMutableTreeNode("child_1"));
              final HideableMutableTreeNode c2 = new HideableMutableTreeNode("child_2");
              c2.setVisible(false);
              final HideableMutableTreeNode c2a = new HideableMutableTreeNode("child_2_A");
              c2.add(c2a);
              c2.add(new HideableMutableTreeNode("child_2_B"));
              root.add(c2);
              HideableMutableTreeNode c3 = new HideableMutableTreeNode("child_3");
              HideableMutableTreeNode cC = new HideableMutableTreeNode("child_3_C");
              cC.setVisible(false);
              c3.add(cC);
              c3.add(new HideableMutableTreeNode("child_3_D"));
              root.add(c3);
              root.add(new HideableMutableTreeNode("child_4"));
              root.add(new HideableMutableTreeNode("child_5"));
              DefaultMutableTreeNode c6 = new DefaultMutableTreeNode("child_6");
              c6.add(new DefaultMutableTreeNode("child_6_A"));
              c6.add(new DefaultMutableTreeNode("child_6_B"));
              root.add(c6);
              final HideableTreeModel model = new HideableTreeModel(root);
              JTree tree = new JTree(model);
              f.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
              JButton b = new JButton("toggle");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        model.setNodeVisible(c2, !model.isNodeVisible(c2));
                        //model.ensurePathToNodeVisible(c2a);
              f.getContentPane().add(b, BorderLayout.SOUTH);
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** HideableMutableTreeNode ***
    import javax.swing.*;
    import javax.swing.tree.*;
    * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
    * implementation that works with <code>HideableTreeModel</code>.
    public class HideableMutableTreeNode extends DefaultMutableTreeNode {
         * The node is visible flag.
         public boolean visible = true;
         * Creates a tree node that has no parent and no children, but which
         * allows children.
         public HideableMutableTreeNode() {
              super();
         * Creates a tree node with no parent, no children, but which allows
         * children, and initializes it with the specified user object.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         public HideableMutableTreeNode(Object userObject) {
              super(userObject);
         * Creates a tree node with no parent, no children, initialized with the
         * specified user object, and that allows children only if specified.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         * @param allowsChildren - if true, the node is allowed to have child
         * nodes -- otherwise, it is always a leaf node
         public HideableMutableTreeNode(Object userObject, boolean allowsChildren) {
              super(userObject, allowsChildren);
         * Checks if the node is visible.
         * @return true if the node is visible, else false
         public boolean isVisible() {
              return this.visible;
         * Sets if the node is visible.
         * @param v true if the node is visible, else false
         public void setVisible(boolean v) {
              this.visible = v;
    // *** TreeNodeTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>TreeNodeTreeModel</code> is an <code>AbstractTreeModel</code>
    * implementation for <code>javax.swing.tree.TreeNode</code> objects.
    public class TreeNodeTreeModel extends AbstractTreeModel {
         * Creates a new <code>TreeNodeTreeModel</code> object.
         * @param root the root node
         public TreeNodeTreeModel(TreeNode root) {
              super();
              setRoot(root);
         * Returns the parent of the child node.
         * @param node the child node
         * @return the parent or null if root
         public Object getParent(Object node) {
              if(node != getRoot() && (node instanceof TreeNode)) {
                   return ((TreeNode)node).getParent();
              return null;
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildAt(index);
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildCount();
              return 0;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   return ((TreeNode)parent).getIndex((TreeNode)child);
              return -1;
         * Returns true if node is a leaf.
         * @param node the node
         * @return true if the node is a leaf
         public boolean isLeaf(Object node) {
              if(node instanceof TreeNode) {
                   return ((TreeNode)node).isLeaf();
              return true;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
              root.add(new DefaultMutableTreeNode("child_1"));
              DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("child_2");
              c2.add(new DefaultMutableTreeNode("child_2_A"));
              c2.add(new DefaultMutableTreeNode("child_2_B"));
              root.add(c2);
              root.add(new DefaultMutableTreeNode("child_3"));
              root.add(new DefaultMutableTreeNode("child_4"));
              JTree tree = new JTree(new TreeNodeTreeModel(root));
              f.getContentPane().add(new JScrollPane(tree));
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** AbstractTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    public abstract class AbstractTreeModel implements TreeModel {
         * The list of tree model listeners.
         private Vector modelListeners = new Vector();
         * The root object of the tree.
         private Object root = null;
         * Basic no-op constructor.
         public AbstractTreeModel() {
         * Gets the root object of the tree.
         * @return the root object
         public Object getRoot() {
              return this.root;
         * Sets the root object of the tree.
         * @param r the root object
         protected void setRoot(Object r) {
              this.root = r;
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @return the path to the object or <CODE>null</CODE>
         public Object[] getPathToRoot(Object node) {
              return getPathToRoot(node, 0);
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @param i the current index
         * @return the path to the object or <CODE>null</CODE>
         private Object[] getPathToRoot(Object node, int i) {
              Object anode[];
              if(node == null) {
                   if(i == 0) {
                        return null;
                   anode = new Object[i];
              } else {
                   i++;
                   if(node == getRoot()) {
                        anode = new Object[i];
                   } else {
                        anode = getPathToRoot(getParent(node), i);
                   anode[anode.length - i] = node;
              return anode;
         * Gets the parent object of the specified object. This method is not
         * part of the <code>javax.swing.tree.TreeModel</code> interface, but is
         * required to support the <code>getPathToRoot(Object)</code> method,
         * which is widely used in this class. Therefore, it is important to
         * correctly implement this method.
         * @param obj the object
         * @parma the parent object or null if no parent or invalid object
         protected abstract Object getParent(Object obj);
         * Adds a listener for the <CODE>TreeModelEvent</CODE> posted after the
         * tree changes.
         * @param l the tree model listener
         public void addTreeModelListener(TreeModelListener l) {
              modelListeners.addElement(l);
         * Removes a listener previously added with addTreeModelListener().
         * @param l the tree model listener
         public void removeTreeModelListener(TreeModelListener l) {
              modelListeners.removeElement(l);
         * Forces the tree to reload. This is useful when many changes occur
         * under the root node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed. To maintain
         * the expanded nodes, see the <code>getExpandedPaths(JTree)</code>
         * and <code>expandPaths(JTree, ArrayList)</code> methods.
         * @see #getExpandedPaths(JTree)
         * @see #expandPaths(JTree, ArrayList)
         public void reload() {
              reload(getRoot());
         * Forces the tree to repaint. This is useful when many changes occur
         * under a specific node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed below the
         * updated node.
         * @param node the node that changed
         public void reload(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeStructureChanged(new TreeModelEvent(this, tp));
         * Messaged when the user has altered the value for the item identified
         * by <CODE>path</CODE> to <CODE>newValue</CODE>.
         * @param path the path to the changed object
         * @param newValue the new value
         public void valueForPathChanged(TreePath path, Object newValue) {
              nodeChanged(path.getLastPathComponent());
         * Notifies the tree that nodes were inserted. The index is looked up
         * automatically.
         * @param node the parent node
         * @param child the inserted child node
         public void nodeInserted(Object node, Object child) {
              nodeInserted(node, child, -1);
         * Notifies the tree that nodes were inserted.
         * @param node the parent node
         * @param child the inserted child node
         * @param index the index of the child
         public void nodeInserted(Object node, Object child, int index) {
              if(index < 0) {
                   index = getIndexOfChild(node, child);
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesInserted(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that nodes were removed. The index is required
         * since by this point, the object will no longer be in the tree.
         * @param node the parent node
         * @param child the removed child node
         * @param index the index of the child
         public void nodeRemoved(Object node, Object child, int index) {
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesRemoved(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that a node was changed.
         * @param node the changed node
         public void nodeChanged(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeNodesChanged(new TreeModelEvent(this, tp, null, null));
         * Fires "tree nodes changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesChanged(event);
         * Fires "tree nodes inserted" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesInserted(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesInserted(event);
         * Fires "tree nodes removed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesRemoved(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesRemoved(event);
         * Fires "tree structure changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeStructureChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeStructureChanged(event);
         * Records the list of currently expanded paths in the specified tree.
         * This method is meant to be called before calling the
         * <code>reload()</code> methods to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public ArrayList getExpandedPaths(JTree tree) {
              ArrayList expandedPaths = new ArrayList();
              addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths);
              return expandedPaths;
         * Adds the expanded descendants of the specifed path in the specified
         * tree to the internal expanded list.
         * @param tree the tree
         * @param path the path
         * @param pathlist the list of expanded paths
         private void addExpandedPaths(JTree tree, TreePath path, ArrayList pathlist) {
              Enumeration enum = tree.getExpandedDescendants(path);
              while(enum.hasMoreElements()) {
                   TreePath tp = (TreePath)enum.nextElement();
                   pathlist.add(tp);
                   addExpandedPaths(tree, tp, pathlist);
         * Re-expands the expanded paths in the specified tree. This method is
         * meant to be called before calling the <code>reload()</code> methods
         * to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public void expandPaths(JTree tree, ArrayList pathlist) {
              for(int i = 0; i < pathlist.size(); i++) {
                   tree.expandPath((TreePath)pathlist.get(i));

    Hey
    I'm not trying to show anyone up here, but having just built a tree model for displaying an XML document in a tree, I thought this seemed like a neat exercise.
    I implemented this very differently from the @OP. I only have one class, HiddenNodeTreeModel. All the hidden node data is stored in the model itself in my class. The advantage of what I've created is it will work with any TreeModel. The disadvantage is that I think it's not going to be very scalable - the additional computing to get the number of child nodes and to adjust indexes is heavy. So if you need a scalable solution definitely don't use this.
    Anyway here you go
    HiddenNodeTreeModel.java
    ======================
    package tjacobs.ui.tree;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import tjacobs.ui.WindowUtilities;
    public class HiddenNodeTreeModel implements TreeModel {
         TreeModel mModel;
         ArrayList<Object> mHidden = new ArrayList<Object>();
         public HiddenNodeTreeModel (TreeModel model) {
              mModel = model;
         public void addTreeModelListener(TreeModelListener arg0) {
              mModel.addTreeModelListener(arg0);
         private ArrayList<Integer> getHiddenChildren(Object parent) {
              ArrayList<Integer> spots = new ArrayList<Integer>();
              Iterator _i = mHidden.iterator();
              while (_i.hasNext()) {
                   Object hidden = _i.next();
                   int idx = mModel.getIndexOfChild(parent, hidden);
                   if (idx != -1) {
                        spots.add(idx);
              return spots;
         public Object getChild(Object arg0, int index) {
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        index++;
              return mModel.getChild(arg0, index);
         public int getChildCount(Object arg0) {
              ArrayList list = getHiddenChildren(arg0);
              System.out.println("size = " + list.size());
              return mModel.getChildCount(arg0) - list.size();
         public int getIndexOfChild(Object arg0, Object arg1) {
              int index = mModel.getIndexOfChild(arg0, arg1);
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              int toSub = 0;
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        toSub++;
              return index - toSub;
         public Object getRoot() {
              // TODO Auto-generated method stub
              return mModel.getRoot();
         public boolean isLeaf(Object arg0) {
              // TODO Auto-generated method stub
              return mModel.isLeaf(arg0);
         public void removeTreeModelListener(TreeModelListener arg0) {
              mModel.removeTreeModelListener(arg0);
         public void valueForPathChanged(TreePath arg0, Object arg1) {
              mModel.valueForPathChanged(arg0, arg1);
         public void hideNode(Object node) {
              if (node instanceof TreePath) {
                   node = ((TreePath)node).getLastPathComponent();
              mHidden.add(node);
         public void showNode(Object node) {
              mHidden.remove(node);
         public void showAll() {
              mHidden.clear();
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              DefaultMutableTreeNode A = new DefaultMutableTreeNode("A");
              DefaultMutableTreeNode B = new DefaultMutableTreeNode("B");
              DefaultMutableTreeNode C = new DefaultMutableTreeNode("C");
              DefaultMutableTreeNode D = new DefaultMutableTreeNode("D");
              DefaultMutableTreeNode E = new DefaultMutableTreeNode("E");
              DefaultMutableTreeNode F = new DefaultMutableTreeNode("F");
              A.add(B);
              B.add(C);
              B.add(D);
              B.add(E);
              E.add(F);
              DefaultTreeModel model = new DefaultTreeModel(A);
              final HiddenNodeTreeModel hmodel = new HiddenNodeTreeModel(model);
              final JTree tree = new JTree(hmodel);
              JFrame jf = new JFrame("HiddenNodeTreeModel Test");
              jf.add(tree);
              JMenuBar bar = new JMenuBar();
              jf.setJMenuBar(bar);
              JMenu menu = new JMenu("Options");
              bar.add(menu);
              final JMenuItem hide = new JMenuItem("Hide");
              final JMenuItem show = new JMenuItem("ShowAll");
              menu.add(hide);
              menu.add(show);
              ActionListener al = new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        if (ae.getSource() == hide) {
                             hmodel.hideNode(tree.getSelectionPath());
                             tree.updateUI();
                        else {
                             hmodel.showAll();
                             tree.updateUI();
              hide.addActionListener(al);
              show.addActionListener(al);
              jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf.setBounds(100,100,100,100);
              jf.setVisible(true);
    }

  • Useful Code of the Day:  Splash Screen & Busy Application

    So you are making an Swing application. So what are two common things to do in it?
    1) Display a splash screen.
    2) Block user input when busy.
    Enter AppFrame! It's a JFrame subclass which has a glass pane overlay option to block input (setBusy()). While "busy", it displays the system wait cursor.
    It also supports display of a splash screen. There's a default splash screen if you don't provide a component to be the splash screen, and an initializer runner which takes a Runnable object. The Runnable object can then modify the splash screen component, for example to update a progress bar or text. See the main method for example usage.
    It also has a method to center a component on another component (useful for dialogs) or center the component on the screen.
    NOTE on setBusy: I do recall issues with the setBusy option to block input. I recall it having a problem on some Unix systems, but I can't remember the details offhand (sorry).
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    * <CODE>AppFrame</CODE> is a <CODE>javax.swing.JFrame</CODE> subclass that
    * provides some convenient methods for applications.  This class implements
    * all the same constructors as <CODE>JFrame</CODE>, plus a few others. 
    * Methods exist to show the frame centered on the screen, display a splash
    * screen, run an initializer thread and set the frame as "busy" to block 
    * user input. 
    public class AppFrame extends JFrame implements KeyListener, MouseListener {
          * The splash screen window. 
         private JWindow splash = null;
          * The busy state of the frame. 
         private boolean busy = false;
          * The glass pane used when busy. 
         private Component glassPane = null;
          * The original glass pane, which is reset when not busy. 
         private Component defaultGlassPane = null;
          * Creates a new <CODE>AppFrame</CODE>. 
         public AppFrame() {
              super();
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified
          * <CODE>GraphicsConfiguration</CODE>. 
          * @param  gc  the GraphicsConfiguration of a screen device
         public AppFrame(GraphicsConfiguration gc) {
              super(gc);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title. 
          * @param  title  the title
         public AppFrame(String title) {
              super(title);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * <CODE>GraphicsConfiguration</CODE>. 
          * @param  title  the title
          * @param  gc     the GraphicsConfiguration of a screen device
         public AppFrame(String title, GraphicsConfiguration gc) {
              super(title, gc);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * icon image. 
          * @param  title  the title
          * @param  icon   the image icon
         public AppFrame(String title, Image icon) {
              super(title);
              setIconImage(icon);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * icon image. 
          * @param  title  the title
          * @param  icon  the image icon
         public AppFrame(String title, ImageIcon icon) {
              this(title, icon.getImage());
          * Initializes internal frame settings. 
         protected void init() {
              // set default close operation (which will likely be changed later)
              setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              // set up the glass pane
              glassPane = new JPanel();
              ((JPanel)glassPane).setOpaque(false);
              glassPane.addKeyListener(this);
              glassPane.addMouseListener(this);
          * Displays a new <CODE>JWindow</CODE> as a splash screen using the
          * specified component as the content.  The default size of the
          * component will be used to size the splash screen.  See the
          * <CODE>showSplash(Component, int, int)</CODE> method description for
          * more details. 
          * @param  c  the splash screen contents
          * @return  the window object
          * @see  #showSplash(Component, int, int)
          * @see  #hideSplash()
         public JWindow showSplash(Component c) {
              return showSplash(c, -1, -1);
          * Displays a new <CODE>JWindow</CODE> as a splash screen using the
          * specified component as the content.  The component should have all
          * the content it needs to display, like borders, images, text, etc. 
          * The splash screen is centered on monitor.  If width and height are
          * <CODE><= 0</CODE>, the default size of the component will be used
          * to size the splash screen. 
          * <P>
          * The window object is returned to allow the application to manipulate
          * it, (such as move it or resize it, etc.).  However, <B>do not</B>
          * dispose the window directly.  Instead, use <CODE>hideSplash()</CODE>
          * to allow internal cleanup. 
          * <P>
          * If the component is <CODE>null</CODE>, a default component with the
          * frame title and icon will be created. 
          * <P>
          * The splash screen window will be passed the same
          * <CODE>GraphicsConfiguration</CODE> as this frame uses. 
          * @param  c  the splash screen contents
          * @param  w  the splash screen width
          * @param  h  the splash screen height
          * @return  the window object
          * @see  #showSplash(Component)
          * @see  #hideSplash()
         public JWindow showSplash(Component c, int w, int h) {
              // if a splash window was already created...
              if(splash != null) {
                   // if it's showing, leave it; else null it
                   if(splash.isShowing()) {
                        return splash;
                   } else {
                        splash = null;
              // if the component is null, then create a generic splash screen
              // based on the frame title and icon
              if(c == null) {
                   JPanel p = new JPanel();
                   p.setBorder(BorderFactory.createCompoundBorder(
                        BorderFactory.createRaisedBevelBorder(),
                        BorderFactory.createEmptyBorder(10, 10, 10, 10)
                   JLabel l = new JLabel("Loading application...");
                   if(getTitle() != null) {
                        l.setText("Loading " + getTitle() + "...");
                   if(getIconImage() != null) {
                        l.setIcon(new ImageIcon(getIconImage()));
                   p.add(l);
                   c = p;
              splash = new JWindow(this, getGraphicsConfiguration());
              splash.getContentPane().add(c);
              splash.pack();
              // set the splash screen size
              if(w > 0 && h > 0) {
                   splash.setSize(w, h);
              } else {
                   splash.setSize(c.getPreferredSize().width, c.getPreferredSize().height);
              centerComponent(splash);
              splash.show();
              return splash;
          * Disposes the splash window. 
          * @see  #showSplash(Component, int, int)
          * @see  #showSplash(Component)
         public void hideSplash() {
              if(splash != null) {
                   splash.dispose();
                   splash = null;
          * Runs an initializer <CODE>Runnable</CODE> object in a new thread. 
          * The initializer object should handle application initialization
          * steps.  A typical use would be:
          * <OL>
          *   <LI>Create the frame.
          *   <LI>Create the splash screen component.
          *   <LI>Call <CODE>showSplash()</CODE> to display splash screen.
          *   <LI>Run the initializer, in which: 
          *   <UL>
          *     <LI>Build the UI contents of the frame.
          *     <LI>Perform other initialization (load settings, data, etc.).
          *     <LI>Pack and show the frame.
          *     <LI>Call <CODE>hideSplash()</CODE>.
          *   </UL>
          * </OL>
          * <P>
          * <B>NOTE:</B>  Since this will be done in a new thread that is
          * external to the event thread, any updates to the splash screen that
          * might be done should be triggered through with
          * <CODE>SwingUtilities.invokeAndWait(Runnable)</CODE>. 
          * @param  r  the <CODE>Runnable</CODE> initializer
         public void runInitializer(Runnable r) {
              Thread t = new Thread(r);
              t.start();
          * Shows the frame centered on the screen. 
         public void showCentered() {
              centerComponent(this);
              this.show();
          * Checks the busy state.
          * @return  <CODE>true</CODE> if the frame is disabled;
          *          <CODE>false</CODE> if the frame is enabled
          * @see  #setBusy(boolean)
         public boolean isBusy() {
              return this.busy;
          * Sets the busy state.  When busy, the glasspane is shown which will
          * consume all mouse and keyboard events, and a wait cursor is
          * set for the frame. 
          * @param  busy  if <CODE>true</CODE>, disables frame;
          *               if <CODE>false</CODE>, enables frame
          * @see  #getBusy()
         public void setBusy(boolean busy) {
              // only set if changing
              if(this.busy != busy) {
                   this.busy = busy;
                   // If busy, keep current glass pane to put back when not
                   // busy.  This is done in case the application is using
                   // it's own glass pane for something special. 
                   if(busy) {
                        defaultGlassPane = getGlassPane();
                        setGlassPane(glassPane);
                   } else {
                        setGlassPane(defaultGlassPane);
                        defaultGlassPane = null;
                   glassPane.setVisible(busy);
                   glassPane.setCursor(busy ?
                        Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) :
                        Cursor.getDefaultCursor()
                   setCursor(glassPane.getCursor());
          * Handle key typed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyTyped(KeyEvent ke) {
              ke.consume();
          * Handle key released events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyReleased(KeyEvent ke) {
              ke.consume();
          * Handle key pressed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyPressed(KeyEvent ke) {
              ke.consume();
          * Handle mouse clicked events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseClicked(MouseEvent me) {
              me.consume();
          * Handle mouse entered events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseEntered(MouseEvent me) {
              me.consume();
          * Handle mouse exited events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseExited(MouseEvent me) {
              me.consume();
          * Handle mouse pressed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mousePressed(MouseEvent me) {
              me.consume();
          * Handle mouse released events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseReleased(MouseEvent me) {
              me.consume();
          * Centers the component <CODE>c</CODE> on the screen. 
          * @param  c  the component to center
          * @see  #centerComponent(Component, Component)
         public static void centerComponent(Component c) {
              centerComponent(c, null);
          * Centers the component <CODE>c</CODE> on component <CODE>p</CODE>. 
          * If <CODE>p</CODE> is null, the component <CODE>c</CODE> will be
          * centered on the screen. 
          * @param  c  the component to center
          * @param  p  the parent component to center on or null for screen
          * @see  #centerComponent(Component)
         public static void centerComponent(Component c, Component p) {
              if(c != null) {
                   Dimension d = (p != null ? p.getSize() :
                        Toolkit.getDefaultToolkit().getScreenSize()
                   c.setLocation(
                        Math.max(0, (d.getSize().width/2)  - (c.getSize().width/2)),
                        Math.max(0, (d.getSize().height/2) - (c.getSize().height/2))
          * Main method.  Used for testing.
          * @param  args  the arguments
         public static void main(String[] args) {
              final AppFrame f = new AppFrame("Test Application",
                   new ImageIcon("center.gif"));
              f.showSplash(null);
              f.runInitializer(new Runnable() {
                   public void run() {
                        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        f.getContentPane().add(new JButton("this is a frame"));
                        f.pack();
                        f.setSize(300, 400);
                        try {
                             Thread.currentThread().sleep(3000);
                        } catch(Exception e) {}
                        f.showCentered();
                        f.setBusy(true);
                        try {
                             Thread.currentThread().sleep(100);
                        } catch(Exception e) {}
                        f.hideSplash();
                        try {
                             Thread.currentThread().sleep(3000);
                        } catch(Exception e) {}
                        f.setBusy(false);
    "Useful Code of the Day" is supplied by the person who posted this message. This code is not guaranteed by any warranty whatsoever. The code is free to use and modify as you see fit. The code was tested and worked for the author. If anyone else has some useful code, feel free to post it under this heading.

    Hi
    Thanks fo this piece of code. This one really help me
    Deepa

  • My bluetooth keyboard (Macnus 3.0) is recognised by my iMac but will  not pair?  I have paired it with my iPad using code 8310 but it still will not pair with my iMac.  Can someone help please?

    My bluetooth keyboard (Macnus brand - bought recently in Thailand)(similar to Mac small keyboard) will pair with my iPad using code 8310,and is recognized by my iMac but will not pair?
    There are very scant instructions with the keyboard and no mention of any code (the code was prompted by my iPad).
    I have followed the instructions but it still will not pair with my iMac!
    Can anyone help please?
    My iMac is 20 inch  Mid 2007 OSX10.9.1 4GB RAM

    Hi All, thank you for you suggestions.  I have been unable to find any website for the maker, but have looked at several Thai/cambodian sites incl <http://www.buycoms.com/Article/8435/index.asp>  which mentions the keyboard being suitable for tablet or windows.  No mention of iMac!  although the box is branded to indicate Mac compatable.
    I'm thinking that maybe it just will not pair with an iMac.
    Ill keep looking for the maker website, which might come on later in the future? maybe?
    thanks again.

  • How to install new fonts using code in java?

    Hi,
    How to install font in a system using java, provided i know the font file's address. Is there any specific class/method available for this purpose? Copying the file to windows/font directory will work for windows, but I think it wont be generic to all operating system. So is there anyway to install a font using code?
    I also want to know how to make the font available only until my application window is open, It must be available to all other external applications like photoshop, word etc., When I close my window it must un-install automatically or be made not available to other applications. Any suggestions? Please do help! Thanks in advance...

    I have already tried the above, But the font created using input stream is available only to my application* and is not viewable in photoshop.*. I realize this. Like I said, I know of no method that will register/deregister the font with the system. You'll have to create your own method that takes the operating system into account.
    String os = System.getPropery("os.name");
    if(os.equals("Windows Vista")) {
    }else if(os.equals("Windows XP")) {
    }else if(os.equals("Windows NT")) {
    }else if(os.equals("Solaris")) {
    AIX
    Digital Unix
    FreeBSD
    HP UX
    Irix
    Linux
    Mac OS
    Mac OS X
    MPE/iX
    Netware 4.11
    OS/2
    Solaris
    Windows 2000
    Windows 95
    Windows 98
    Windows NT
    Windows Vista
    Windows XPYou'll need the standard font directory for each system. I think all the window ones are C:\Windows\Font\ . Each OS probably has its own little quark (like having several font directories or throwing different security exceptions). Undoubtly it's going to require some research and a bit of trial and error. You can probably work some magic with Runtime.exec(...) as well.
    The alternative would be to google for some libraries that offer similar functionality, or promt the user for the system's font directory and save the location of the directory in a file somewhere for future use (so the user dosen't have to specify the font directory everytime he/she starts up the application).

  • Using code of odisqlunload in a procedure...

    hi...
    I m using code for ODISQLUNLOAD in a procedure....
    code is :
    Command on target:
    OdiSqlUnload "-FILE=" "-DRIVER=<%=odiRef.getInfo("SRC_JAVA_DRIVER")%>" "-URL=<%=odiRef.getInfo("SRC_JAVA_URL")%>" "-USER=<%=odiRef.getInfo("SRC_USER_NAME")%>" "-PASS=<%=odiRef.getInfo("SRC_ENCODED_PASS")%>" "-FILE_FORMAT=FIXED" "-ROW_SEP=\r\n" "-DATE_FORMAT=yyyy/MM/dd HH:mm:ss" "-CHARSET_ENCODING=ISO8859_1" "-XML_CHARSET_ENCODING=ISO-8859-1"
    "-FETCH_SIZE=5000"
    "select 1 from dual "
    but when i execute it ..it gives me error saying : invalid SQL statement
    I tried
    select 1 from dual...etc but error remains the same....
    my target technology is file......
    where i m going wrong??

    Hi,
    You cant select FILE as target technology when u are using ODI Tools. You need to select ODI Tools ( in 11g) or Sunopsis API (in 10g) as such.
    So i assume ur requirement is to export data from RDBMS table "dynamically" using Odi tools.
    If my understanding is right. Do the below steps to achieve the same.
    1. In the procedure, create an OPTION, lets say, UNLOAD_DIR, Type- Value, Description- Unload Directory, Default Value- D:\SampleData (here u need to mention ur directory, in case if you changed ur directory in future u can only need to change the code here).
    2. Create a new step in Procedure and add the below code in Command on Target, selecting ODI TOOLS or SUOPSIS API as technology,
    OdiSqlUnload "-FILE=<%=snpRef.getOption("UNLOAD_DIR")%>\<%=snpRef.getSession("SESS_NO")%>.txt" "-DRIVER=<%=odiRef.getInfo("SRC_JAVA_DRIVER")%>" "-URL=<%=odiRef.getInfo("SRC_JAVA_URL")%>" "-USER=<%=odiRef.getInfo("SRC_USER_NAME")%>" "-PASS=<%=odiRef.getInfo("SRC_ENCODED_PASS")%>" "-FILE_FORMAT=VARIABLE" "-ROW_SEP=\r\n" "-DATE_FORMAT=yyyy/MM/dd HH:mm:ss" "-CHARSET_ENCODING=ISO8859_1" "-XML_CHARSET_ENCODING=ISO-8859-1"
    select sysdate from dual
    Command on source:
    Technology- Oracle
    Logical Schema- Whichever points to Oracle
    Context- Global/Whichever points to the above logical schema.
    Output:
    In D:\SampleData, u may find a file name with the session number and value as sysdate.
    Makes sense?
    Thanks,
    Guru

  • Do I have to use code in order to post my video on itunes?

    do I have to use code in order to post my video on itunes?
    Is there a uploader app than can help me avoid having to write a tremendous amout of code just to upload ONE film?
    thank you
    Al

    You can not upload your videos to iTunes.  iTunes podcasting section is just a directory of Podcast RSS feeds.
    You will need to go to a 3rd party host such as Libsyn.com to upload your videos and then take the RSS feed from your libsyn account and submit that to iTunes.

Maybe you are looking for

  • How to get the connected Adapter Object for a particular BDoc Type?

    Hi All, I have a scenario in which CRM system is connected to ERP system. In SMW01 transaction, I can see one BDoc with BUS_TRANS_MSG as the BDoc Type in CRM. Now, how do I get to know if this one BDoc is a SALESDOCUMENT or SALESCONTRACT. Is there an

  • Piece of cake!

    I have been watching the bounds for 2 days now and was getting worried about the IOS 5 update. Finally decided to risk it tonight since I figured the servers would get busy tomorrow with the new phone coming out. Updated my IPad first since I could l

  • Text Shift Uncontrollably Inside Accordion Widget

    Guys hi! I've been crashing my head for two days with this. Hope you will provide some help! I have an Accordion Widget with a very long text block inside one of the boxes (a list with over 80 lines). On the background to each second line I put a gre

  • Reg:sql loader in Forms 10g

    Hai, we used sqlldr in forms 6i using host command. Later we upgraded to forms 10g but now the host command is not working. we are able to create directory with the host command, but not able to invoke sqlldr, also forms 10g is not giving any error a

  • Publisher "link to this report" throwing js error

    When viewing a report I'm getting a javascript error when trying to click "Link to this report": 'reportLinksMenu' is not defined. Anyone else having this issue?