Access Another Class' Property Value That is Defined in the faces-config?

I have a private property "dataTransferType" with public getter and setter in the DataFile class. The initial value of the "dataTransferType" is defined in the faces-config.xml file. I want to get the "initial value" of the "dataTransferType" in another class and the compiler does not like the way I access this property.
Here is the snippet of the DataFile class, which shows the declaration and the getter and setter for the property:
public class DataFile implements java.io.Serializable
     private String dataTransferType;
     public DataFile(){}
    public DataFile( String aDataTransferType )
        this.dataTransferType = aDataTransferType;
     public String getDataTransferType()
          return dataTransferType;
     public void setDataTransferType( String dataTransferType )
          this.dataTransferType = dataTransferType;
}Here is the way that the initial value of the "dataTransferPropery" is set in the faces-config.xml file:
<managed-bean>
  <managed-bean-name>dataFile</managed-bean-name>
  <managed-bean-class>propertyBeans.DataFile</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>dataTransferType</property-name>
   <property-class>java.lang.String</property-class>
   <value>importFile</value>
  </managed-property>
</managed-bean>Now, in another class FileManagementBean, I first instantiate the DataFile class
private DataFile datafile;and then in the constructor of the FileManagementBean I tried to access the initial value of the property "dataTransferType":
this.recordItems = this.getRecordsList( datafile.dataTransferType );The compiler did not like it at all.
But, if I arbitrary introduced a String in the FileManagementBean:
String defaultSelectedDataTransferType = "importFile";
this.recordItems = this.getRecordsList( defaultSelectedDataTransferType );My code worked as I had expected without any problem.

Thanks for all your attention.
The runtime error is rather strange:
>
javax.servlet.ServletException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'actions.DataManagementBean'.. class actions.DataManagementBean : java.lang.NullPointerException
The DataManagementBean is the class that accesses the property "dataTransferType" in the DataFile class. And the initial value of the "dataTransferType" is defined in the faces-config.xml file.
If I arbitrarily introduced a String value in the DataManagementBean:
String defaultSelectedDataTransferType = "importFile"and in the DataManagementBean's constructor, I use this statement:
this.recordItems = this.getRecordsList( defaultSelectedDataTransferType );Things worked as I had expected without problem. But, I think this is not an elegant way of coding it. Because there is a pre-defined value of dataTransferType in the faces-config.xml file, I should access it from there.
But, when I specify:
this.recordItems = this.getRecordsList( datafile.getDataTransferType() );The DataManagementBean cannot even be instantiated!
In my faces-config.xml file, I have:
<managed-bean>
  <managed-bean-name>dataManagementBean</managed-bean-name>
  <managed-bean-class>actions.DataManagementBean</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>datafile</property-name>
   <property-class>propertyBeans.DataFile</property-class>
   <value>#{dataFile}</value>
  </managed-property>
</managed-bean>
<managed-bean>
  <managed-bean-name>dataFile</managed-bean-name>
  <managed-bean-class>propertyBeans.DataFile</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>dataTransferType</property-name>
   <property-class>java.lang.String</property-class>
   <value>importFile</value>
  </managed-property>
</managed-bean>
......

Similar Messages

  • How can I access another class in a MembershipRule's Expression

    Hello,
    I want to create an InstanceGroup using Module Microsoft.SystemCenter.GroupPopulator.
    I need to collect all Logical Disks which contain an MS SQL DB Log File.
    I would start as follows:
    <DataSource ID="DS" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
      <RuleId>$MPElement$</RuleId>
      <GroupInstanceId>$Target/Id$</GroupInstanceId>
      <MembershipRules>
        <MembershipRule>
          <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.LogicalDisk"]$</MonitoringClass>
          <RelationshipClass>$MPElement[Name="MSIL!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>     
    <Expression>
            <And>
      <!--
       First Expression
      -->
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <Property>$MPElement[Name="Windows!Microsoft.Windows.LogicalDevice"]/Name$</Property>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
      <!--
        How can I access another class's properties ? 
      -->
                    <GenericProperty>$MPElement[Name="SQL!Microsoft.SQLServer.2008.DBLogFile"]/Drive$</GenericProperty>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <HostProperty>
                      <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]</MonitoringClass>
                      <Property>PrincipalName</Property>
                    </HostProperty>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <GenericProperty>$MPElement[Name="SQL!Microsoft.SQLServer.2008.DBLogFile"]/Drive$</GenericProperty>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </And>
          </Expression>
        </MembershipRule>
      </MembershipRules>
    </DataSource>
    In the first expression you "see" my question:
    I want to compare the LogicalDisk's Name Property with the DB Log File's Drive property.
    But how can I access the DB Log File's Drive property in this MembershipRule ?
    Furthermore LogicalDisk and DB Log File must be hosted on the same Windows Computer.
    Would be great if somebody could help.
    Thanks
    Sebastian

    Hi Niki,
    thanks for the idea, but that will not work. $Target/Id$ refers always to the group to be discovered.
    On last week end I was given following idea, hope it will work:
    Step 1
    Collect all the DB SQL Logfile Objects and write computername (PrincipalName?) and Driveletter into a textfile, line by line. Shouldn't be a problem, PowerShell is your friend.
    Step 2
    Read the file from Step 1, build discovery data for each disk drive as object of class "Logical Disk (Server)",
    and then discover the containment-relationships from those Logical Drive(Server) Objects to the InstanceGroup.
    Perhaps I must do it for the OS-Version related Disks, because I need the target classes  of the Logical Disk Freespace monitors. Some more work. "Risks": I donot know the discovery algorithm for the Logical Disk(Server) Objects, but a "deep
    dive" into the MPs should help.
    Thanks to all, who have read.
    I will inform you about progress and success
    sebastian

  • Error won't let me access another class(has got me tearing my hair off)

    Alright peeps, so basically i have 2 buttons in the mainfraime class. The first button leads to the contestant's page and the second to the voters page. The first button works and directs the user to the PasswordDemo page, but to the hell of me i cant figure out why it refuses to recognize the "Profile" class that its supposed to go to when the user clicks the second button. It keeps on telling me that "The method Profile() is undefined for the type Mainframe". Please help.
    Mainframe class:
    //The applications first or the main frame
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Mainframe extends JFrame {
            private JButton myFirstButton;
            private JButton mySecondButton;
            private javax.swing.JButton jButton1;
            private javax.swing.JButton jButton2;
            private javax.swing.JLabel jLabel1;
            private javax.swing.JLabel jLabel2;
            private javax.swing.JLabel jLabel3;
            // Constructor for a new frame
            public Mainframe() {
                    super("Welcome Page");
                    myFirstButton = new JButton("Contestant");
                    myFirstButton.setFont(new Font( "Arial", Font.BOLD, 18));
                    myFirstButton.setBackground(Color.red);
                    mySecondButton = new JButton("Voter");
                    mySecondButton.setFont(new Font( "Arial", Font.BOLD, 18));
                    mySecondButton.setBackground(Color.ORANGE);
                    Container c = getContentPane();
                    FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
                    c.setLayout(fl);
                    c.add (myFirstButton);
                    c.add (mySecondButton);
                    ButtonHandler handler = new ButtonHandler();    //creation of a new Object
                    myFirstButton.addActionListener(handler);          // Attach/register handler to myFirstButton
                    mySecondButton.addActionListener(handler);        //Attach/register handler to mySecondButton
                    setSize(400, 300);
                    show();
            public static void main(String [] args) {
                    // Make frame
                    Mainframe f = new Mainframe();
                    f.addWindowListener(
                            new WindowAdapter() {
                                    public void windowClosing(WindowEvent e) {
                                            // This closes the window and terminates the
                                            // Java Virtual Machine in the event that the
                                            // Frame is closed by clicking on X.
                                            System.out.println("Exit via windowClosing.");
                                            System.exit(0);
            } // end of main
            // inner class for button event handling
            private class ButtonHandler implements ActionListener {
                    public void actionPerformed(ActionEvent e) {
                            if (e.getSource() == myFirstButton) {
                                 PasswordDemo inputForm = new PasswordDemo();
                                    //inputForm.setVisible(true);
                                    try
                                    PasswordDemo.createAndShowGUI();
                                    inputForm.setVisible(false);
                                    catch(Exception d)
                                   // new PasswordDemo();
                            if (e.getSource() == mySecondButton) {
                           //     Profile p = Profile();
                           //     p.setVisible(true);
            public void actionPerformed (ActionEvent e)
                String cmd = e.getActionCommand();
                if (mySecondButton.equals(cmd)) {
                     boolean success=true;
                     if(success)
                     Profile p = Profile();
                       p.setVisible(true);
          //  private void mySecondButtonActionPerformed(java.awt.event.ActionEvent evt)
         //        Profile p = Profile();
         //       p.setVisible(true);
    } // end of outer class
    }Profile class:
    import java.awt.event.ActionListener;
    import java.sql.*;
    public class Profile extends javax.swing.JFrame {
        public Profile() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            titleLabel = new javax.swing.JLabel();
            nameAccess = new javax.swing.JLabel();
            ageAccess = new javax.swing.JLabel();
            heightAccess = new javax.swing.JLabel();
            weightAccess = new javax.swing.JLabel();
            lastNameAccess = new javax.swing.JLabel();
            descriptionAccess = new javax.swing.JLabel();
            nameLabel = new javax.swing.JLabel();
            lastNameLabel = new javax.swing.JLabel();
            ageLabel = new javax.swing.JLabel();
            heightLabel = new javax.swing.JLabel();
            weightLabel = new javax.swing.JLabel();
            descriptionLabel = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            titleLabel.setFont(new java.awt.Font("Gungsuh", 1, 18)); // NOI18N
            titleLabel.setText("\"User\"'s Profile");
            nameAccess.setText("Name: ");
            nameLabel.setText("");
            lastNameAccess.setText("Last Name: ");
            lastNameLabel.setText("");
            ageAccess.setText("Age: ");
            ageLabel.setText("");
            heightAccess.setText("Height: ");
            heightLabel.setText("");
            weightAccess.setText("Weight: ");
            weightLabel.setText("");
            descriptionAccess.setText("Description: ");
            descriptionLabel.setText("");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(nameAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(nameLabel))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(lastNameAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lastNameLabel))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(ageAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(ageLabel))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(heightAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(heightLabel))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(weightAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(weightLabel))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(descriptionAccess)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(descriptionLabel)))
                    .addContainerGap(151, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(titleLabel)
                    .addGap(13, 13, 13)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(nameAccess)
                        .addComponent(nameLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lastNameAccess)
                        .addComponent(lastNameLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(ageAccess)
                        .addComponent(ageLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(heightAccess)
                        .addComponent(heightLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(weightAccess)
                        .addComponent(weightLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(descriptionAccess)
                        .addComponent(descriptionLabel))
                    .addContainerGap(139, Short.MAX_VALUE))
            pack();
        }// </editor-fold>
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Profile().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JLabel ageAccess;
        private javax.swing.JLabel ageLabel;
        private javax.swing.JLabel descriptionAccess;
        private javax.swing.JLabel descriptionLabel;
        private javax.swing.JLabel heightAccess;
        private javax.swing.JLabel heightLabel;
        private javax.swing.JLabel lastNameAccess;
        private javax.swing.JLabel lastNameLabel;
        private javax.swing.JLabel nameAccess;
        private javax.swing.JLabel nameLabel;
        private javax.swing.JLabel titleLabel;
        private javax.swing.JLabel weightAccess;
        private javax.swing.JLabel weightLabel;
        // End of variables declaration
    }PasswordDemo class:
    import javax.swing.*;
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Arrays;
    import java.net.*;
    import java.io.*;
    import java.util.Scanner;
    public class PasswordDemo extends JPanel
                              implements ActionListener  {
        private static String OK = "ok";
        private static String HELP = "help";
        private static String Register = "Register";
        private JFrame controllingFrame; //needed for dialogs
        private JTextField username;
        private JPasswordField passreg;
        private JTextField usernamefield;
        private JPasswordField passwordField;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private JTextField name;
        private JTextField age;
        private JTextField height;
        private JTextField weight;
    private javax.swing.JPanel jPanel1;
        private void gothere() {
                      JFrame f = new JFrame("This is a test");
                      f.setSize(400, 300);
                      Container content = f.getContentPane();
                      content.setBackground(Color.white);
                      content.setLayout(new FlowLayout());
                     // content.add(new JButton("Button 1"));
                      //content.add(new JButton("Button 2"));
             name = new JTextField("Please put your name here", 20);
              name.setFont(new Font("Serif", Font.PLAIN, 14));
              content.add(name);
              age = new JTextField("Please put your age here", 20);
              age.setFont(new Font("Serif", Font.PLAIN, 14));
              content.add(age);
              height = new JTextField("Please indicate your height here", 20);
              height.setFont(new Font("Serif", Font.PLAIN, 14));
              content.add(height);
              weight = new JTextField("Please indicate your weight here", 20);
              weight.setFont(new Font("Serif", Font.PLAIN, 14));
              content.add(weight);
              content.add(new JButton("Submit"));
               f.setVisible(true);
         public PasswordDemo(JFrame f) throws Exception {
            //Use the default FlowLayout.
            controllingFrame = f;
            //Create everything.
            usernamefield = new JTextField(10);
            usernamefield.setActionCommand(OK);
            usernamefield.addActionListener(this);
            passwordField = new JPasswordField(10);
            passwordField.setActionCommand(OK);
            passwordField.addActionListener(this);
            passreg = new JPasswordField(10);
            passreg.setActionCommand(Register);
            passreg.addActionListener(this);
            username = new JTextField("This is a sentence", 20);
            username.setActionCommand(Register);
            username.addActionListener(this);
            JLabel reg = new JLabel("If you are a new contestant please register: \n");
            JLabel user = new JLabel("Username: \n");
            user.setLabelFor(username);
            JLabel pass = new JLabel("Password: \n");
            user.setLabelFor(passreg);
            JLabel label = new JLabel("Enter your username and password to log in: ");
            label.setLabelFor(usernamefield);
            label.setLabelFor(passwordField);
            JComponent buttonPane = createButtonPanel();
            //Lay out everything.
            JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
            textPane.add(reg);
            textPane.add(user);
            textPane.add(pass);
            textPane.add(username);
            textPane.add(passreg);
            textPane.add(label);
            textPane.add(usernamefield);
            textPane.add(passwordField);
            add(textPane);
            add(buttonPane);
        public PasswordDemo() {
              // TODO Auto-generated constructor stub
         protected JComponent createButtonPanel() {
            JPanel p = new JPanel(new GridLayout(0,1));
            JButton okButton = new JButton("OK");
            JButton helpButton = new JButton("Help");
            JButton regButton = new JButton("Register");
            okButton.setActionCommand(OK);
            helpButton.setActionCommand(HELP);
            regButton.setActionCommand(Register);
            okButton.addActionListener(this);
            helpButton.addActionListener(this);
            regButton.addActionListener(this);
            p.add(okButton);
            p.add(helpButton);
            p.add(regButton);
            return p;
        public void actionPerformed (ActionEvent e)
            String cmd = e.getActionCommand();
            if (OK.equals(cmd)) { //Process the password.  
                boolean success=true;                        //Sign In
                 String Username="";
                 String Password="";
                 Username = this.usernamefield.getText();
                 Password = this.passwordField.getText();
                 try
                     success=check2(Username,Password);
                 catch(Exception d)
                      System.out.println("Got out");
                 if(success)
                 JOptionPane.showMessageDialog(controllingFrame, "Sign in Successful");
                 Form F = new Form(Username);
                 F.setVisible(true);
                 else
                 JOptionPane.showMessageDialog(controllingFrame, "Sign in was unsuccessful");     
            else if(HELP.equals(cmd)) { //The user has asked for help.
                JOptionPane.showMessageDialog(controllingFrame,
                    "You can get the password by searching this example's\n"
                  + "source code for the string \"correctPassword\".\n"
                  + "Or look at the section How to Use Password Fields in\n"
                  + "the components section of The Java Tutorial.");
            else if(Register.equals(cmd)) {  //*****************************************************
                 boolean success=true;
                 String Username="";
                 String Password="";
                 Username = this.username.getText();
                 Password = this.passreg.getText();
                 try
                      success=check(Username,Password);
                 catch(Exception d)
                      System.out.println("Something bad happened");
                 if(success)
                 JOptionPane.showMessageDialog(controllingFrame, "Registration successful");
                 else
                 JOptionPane.showMessageDialog(controllingFrame, "Registration was unsuccessful");
        //Must be called from the event dispatch thread.
        protected void resetFocus() {
            passwordField.requestFocusInWindow();
        static void createAndShowGUI() throws Exception {
            //Create and set up the window.
            JFrame frame = new JFrame("Registration Page");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            final PasswordDemo newContentPane = new PasswordDemo(frame);
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Make sure the focus goes to the right component
            //whenever the frame is initially given the focus.
            frame.addWindowListener(new WindowAdapter() {
                public void windowActivated(WindowEvent e) {
                    newContentPane.resetFocus();
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String args[]) {
            //Schedule a job for the event dispatch thread:
            //creating and showing this application's GUI.
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    //Turn off metal's use of bold fonts
              UIManager.put("swing.boldMetal", Boolean.FALSE);
              try{
              createAndShowGUI();
                catch(Exception e)
        public void sendUserPass(String user,String pass)throws Exception
             //Send request
             Class.forName("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection("jdbc:mySql://localhost:3306/Contest","root","");
              System.out.println("connected :D:D:D:D");
              PreparedStatement state = con.prepareStatement("Insert Into Contestant (USERNAME,PASSWORD) values ('"+user+"','"+pass+"')");
              state.executeUpdate();
              /*while(Result.next())
                   System.out.println(Result.getString(1)+"\t"+Result.getString(2));
              //server should reply by updating database
        public boolean check(String user,String pass)throws Exception
             //Send request
             Socket Sock = new Socket ("LocalHost",5000);
             DataOutputStream toServer = new DataOutputStream(Sock.getOutputStream());
             BufferedReader buff = new BufferedReader(new InputStreamReader(Sock.getInputStream()));
             String sentence="";
             toServer.writeBytes("1\n");
             sentence=buff.readLine();
             System.out.println(sentence+"\n");
             toServer.writeBytes(user+" "+pass+"\n");
             String answer="";
             answer = buff.readLine();
             if(answer.equals("No"))
                  return false;
             return true;
             /*Class.forName("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection("jdbc:mySql://localhost:3306/Contest","root","");
              System.out.println("connected :D:D:D:D");
              PreparedStatement state = con.prepareStatement("Select Username From Contestant where '"+user+"'= username");
              ResultSet Result = state.executeQuery();
              if(!Result.next())
              return true;*/
              //server should reply by updating database
        public boolean check2(String user,String pass)throws Exception
             Socket Sock = new Socket("localhost",5000);
             DataOutputStream toServer = new DataOutputStream (Sock.getOutputStream());
             BufferedReader buff = new BufferedReader(new InputStreamReader(Sock.getInputStream()));
             toServer.writeBytes("2\n");
             System.out.println("Well I sent the message");
             String sentence = buff.readLine();
             toServer.writeBytes(user+" "+pass+"\n");
             System.out.println(sentence);
             sentence=buff.readLine();
             System.out.println(sentence+"\n");
             if(sentence.equals("No"))
                  return false;
             return true;
    }

    Profile p = Profile();That says "call a method name 'Profile' that's defined in the current class."
    Perhaps what you meant was:
    Profile p = new Profile();which says "create a new instance of the Profile class, and invoke its no-arg constructor."

  • Access another class function

    Hey,
    I am trying to access another class function. I have 2 Classes and my main menu features are in my Main Class and I want to call that function from my Level Class
    What is a good idea to approach this, some how I need to import it in a way but I don't know how I could do that.
    Thanks,
    McbainGames11

    Fixed it myself
    Answer:
                        public static var instance:Main;
                        public function Main()
                                  instance = this;
    And I called a function from Main Class in my Level Class using:
    Main.instance.function();

  • Accessing another class

    A have my "main" class (a JPanel) and the thing I want to do is simply to access another class' data and methods through my main class (That class also extending JPanel and is added together with the main class to a JFrame in a third class). The thing is i have this JTextPane that i wished to edit from my main class. Like:
    //Main class
    public class Main extends JPanel {
         private class Listener implements KeyListener{
              public void keyPressed(KeyEvent ke) {
                   if (ke.getKeyCode() == foo){
                        //Do like:
                        Log.appendLogText(bar);
    }//My JTextPane handling class
    public class Log extends JPanel {
         private JTextPane logText;
         public Log(){
              logText = new JTextPane();
              logText.setContentType("text/html");
         public void appendLogText(String str){
              String text = str;
              Document textDoc = tempLogText.getDocument();
              int end = textDoc.getLength();
              try {
                   textDoc.insertString(end, text, logText.getLogicalStyle());
                   logText.setText(textDoc.getText(0, textDoc.getLength()));
              } catch (BadLocationException e) {}
    }This is just scraps of code, if there is a better way to do it please tell me, what i want is (again) simply one JPanel displaying something where you can edit the JTextPane in another JPanel (and class).

    public class Main extends JPanel {
        private Log log;
        public void setLog(Log log) {
            this.log = log;
        log.appendLogText(bar);
    }It's up to the builder code that instantiates Main and Log classes to call:
    tehMain.setLog(tehLog);For an extra schmear of abstraction, you can do this variant:
    public interface ILog {
        void appendLogText(String s);
    public class Main extends JPanel {
        private ILog log;
        public void setLog(ILog log) {
            this.log = log;
        log.appendLogText(bar);
    public class Log extends JPanel implements ILog {...}That way, you can pass Main other ILogs -- for testing Main, for example.

  • Accessing entity class field values in a visual JSF page

    There is a convenient way to access a session values into a JSF visual page using the following:
    String mySessionValue = (String) getValue("#{sessionScope.name}");Like the same, are there any ways to access entity class field values into a visual JSF page? Are there any concepts similar to "entityClassDataProvider" that can be linked to a table component in a visual JSF page?
    Thank you.

    My question is about (Netbeans visual pack) Java Persistence API and how to display the information from an entity class to a JSF page. But the above mentioned tutorial is about the ordinary visual table presentation.
    Thank you.

  • Restrict filter values that are shown in the selection screen

    Hi Experts
    1) Is it possible to restrict the filter values that are shown in the selection screen in BEx web? When a user are asked to enter a material number and uses the selection button in BEx web, he should only see material numbers for one specific plant. How is this done? 
    2) Is it possible to remove the selection button for å characteristic filter in the selection screen in BEx web? The selection button I am talking about is the button to the right of where you enter the filter value (two white papers on top of each other). If there is no solution for question 1 we have to go for question 2 solution.
    We are using BI 04s, SP 09.
    Kind regards
    Erik

    Hi Erik,
    It seems that you would like the user to see value for 1 single plant. If the Plant Value is fixed then you can use this value in the Query and hardcode it.> in the query go to the Plant Chrac and keep a constant value of the Plant.
    How ever if you need this value to be dynamic then use a variable for customer exit and populate this value using ABAP.
    Regards,
    Jasprit

  • How to retrieve a property value from an iview in the back-end?

    Hi,
    I am looking for a back-end function module or any other way to retrieve the property value of an iview in the portal.
    Is this possible?
    thanks,
    Bert Caryn

    Hi,
    Look at the following threads,
    For programmatically getting the iview properties,
    Programmatically getting iView Properties
    Also,
    Get Properties of IView Programmatically
    Permanent change of iView property programmatically
    Hope these threads help u.
    Regards
    Srinivasan T

  • Convert an integer value that was created with the Excel DATEVALUE formula to a valid date?

    Hello everyone,
    How can I convert an integer value that was created with the Excel DATEVALUE formula to a valid date in SSIS?
    Is this even possible?
    For example:
    =DATEVALUE("8/22/2008") will format the cell to display 39682.
    Reading the column as a string to get the int value (39682) - how can I turn this into a valid date using SSIS and then importing the real date to sql server?
    Thank you!

    You can use Script component for this and convert your integer values to Date. An example here is following:
    CultureInfo provider = CultureInfo.InvariantCulture;
    string dateString = "08082010";
    string format = "MMddyyyy";
    DateTime result = DateTime.ParseExact(dateString, format, provider);
    Source: http://stackoverflow.com/questions/2441405/converting-8-digit-number-to-datetime-type
    Vikash Kumar Singh || www.singhvikash.in

  • Calling a method from another class... that requires variables?

    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
         cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), but I'm not sure how! I have tried, but then I get errors such as ')' expected?
    Any ideas! :D

    f1d wrote:
    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
    cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), seems that way from the error you posted
    but I'm not sure how!
    setDate(16, 6, 2008);
    I have tried, but then I get errors such as ')' expected?
    Any ideas! :Dyou need to post your code if you're getting specific errors like that.
    but typically ')' expected means just that, you have too many or not enough parenthesis (or in the wrong place, etc.)
    i.e. syntax error

  • How do you set a default format property for a formula defined in the AWM?

    Is there a way to define a default format property for a formula that I create in the AW?
    For example, if I define a formula in AW I can assign it a datatype of decimal. But what property do I need to add if want that formula to by DEFAULT always display a certain way, regardless if I use the Discover Plus with OLAP option or OracleBI Spreadsheet Addin?
    Example: want to display it by default, in the AW cube, as being associated to a format of 00.0000 or 00.0000% or $###,##0.00 etc. This way, no mater what tool I use to view the cube, it will by default inherit my default format (set in the AW).
    Thanks.

    Okay, but if I use the out-of-the-box products Oracle provides (ie: Discover Plus with Olap, and the OracleBI Spreadsheet Addin) I still dont understand what my solution is?
    The only other solution we tried was to create formulas using AWM template files. The issue here is trying to find out what property syntax needs to be added to the XML code, so that my formula, by default, is associated to a certain formating style (ie: 00.00). And then when you reference that formula in those out-of-the-box Oracle products, it displays as expected.

  • Access KM predefined property values from a Web Dynpro application

    Hi,
    I am trying to build a custom search interface in Web Dynpro which leverages the KMC Indexing and Search services.
    In this interface I would like to display value lists of predefined properties in KM (created using the Property Metadata Service) and bind each predefined property's value list to a checkbox group UI element.
    Which KM API should I use to retrieve the values of a specific predefined property ?
    When using the standard flexible user interface in the portal this can easily be achieved through configuration, but now I would like to know how to achieve this in Java code.
    Thanks in advance for your input.
    I have some idea on how to get the propertymap from a resource, but how can I access the metadata of a predefined property in KM directly ?

    Hi Theo, i'm working on something like this, i have a WD application that is accessing Km through a Webservice, on the webservice ejb i have this problem:
    IResourceFactory resFactory = ResourceFactory.getInstance();
    IRepositoryServiceFactory serFactory = resFactory.getServiceFactory();
    IPropertyConfigurationService propConfigService = (IPropertyConfigurationService) serFactory.getService("PropertyConfigurationService");
    IMetaNameListIterator i = propConfigService.getMetaModel().nameIterator();
         while (i.hasNext()) {
         IMetaName metaname = i.next();
         if ( metaname.getDocumentPatterns()!= null){
         propertyData.setId(metaname.getName());
         propertyData.setName(metaname.getLabel(locale));
         propertyData.setNamespace(metaname.getNamespace());
         propertyData.setDescription(metaname.getDescription(locale));
                    propertyList.add(propertyData);
    On this line serFactory.getService("PropertyConfigurationService") i get the following error on the trace:
    #System.err#sap.com/KmmsListEAR#System.err#Guest#2####30a27fa0cbfa11dbace30018de0545f1#SAPEngine_Application_Thread[impl:3]#Error##Plain###Configuration Framework error: unable to create an IConfigClientContext instance from an EP5 userInitialConfigException: The configuration service locator could not be initialized for any of the environments. The configuration framework is not available.#
    #System.err#sap.com/KmmsListEAR#System.err#Guest#2####30a27fa0cbfa11dbace30018de0545f1#SAPEngine_Application_Thread[impl:3]#Error##Plain###InitialConfigException: The configuration service locator could not be initialized for any of the environments. The configuration framework is not available.
    Do you have any idea of how to solve this? or if you accomplished in a different way, can you guide me a little bit.
    Thanks in advance Theo

  • Help... dont know what's the problem.. accessing another class

    (im new to java =c)
    well i have a file named accessfiles.java as my main page and i have another java file named try1.java
    i can access try1.java from accessfiles.java using a simple case..... but how come i cant return to accessfiles.java?
    is it with the string[]args?? do i have to erase it?
    please help me =c
    accessfiles.java
    import java.io.*;
    public class accessfiles{
    public static void main(String[]args)throws Exception{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("\nMAIN MENU");
    System.out.println("[1] for Prelim MP1");
    System.out.print("CHOICE: ");
    switch(c)
    case 1:
         try m1=new try1();
         m1.try();
         break;
    default: System.out.println("Invalid Input!");
         break;
    try1.java
    import java.io.*;
    public class try1 {
         public static void try()throws Exception
              BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
              int x=0;
              int y=0;                    
              int r=0;
         System.out.println("1st Pattern");
         for (x=1;x<=5;x++)
         System.out.println(" ");
         r=x;
         for (y=1;y<=r;y++)
         System.out.print(y);
         System.out.println(" ");
         System.out.println(" ");
         System.out.println("2nd Pattern");
         for (x=5;x>=1;x--)
         System.out.println(" ");
         r=x;
         for (y=1;y<=r;y++)
         System.out.print(y);
    accessfiles m2=new accessfiles();
         m2.main();
         break;
    }

    For starters, you don't seem to understand the difference between a static and non-static method. Here is an example of how to call a method in a different class.
    public class MainClass {
        public static void main(String[] args) {
            MainClass app = new MainClass();
            app.go();
        public void go() {
            System.out.println("start of go");
            another.method();
            System.out.println("end of go");
        private AnotherClass another = new AnotherClass();
    public class AnotherClass {
        public void method() {
            System.out.println("method");
    }

  • Pair, and also accessing another class's vars

    Hi, two things:
    1) If some variable was set equal to Pair(obj1, obj2) what exactly does this mean? Is Pair some specialized type of 2-element array? Can you use Pair[0] to get the first element?
    2) If another Object has, in its definition, a public variable, should I use Objectname.variable to get access to it if they don't provide a get() method?

    2) If another Object has, in its definition, a public
    variable, should I use Objectname.variable to get
    access to it if they don't provide a get() method?Yes, you access all instance members the same way: reference.member

  • Can I use a inputHidden for javascript values that doesn't set the value?

    I have a hiddenInput field for each row in a datatable so I can restore default values to a date field with a javascript function. I am getting conversion errors because I don't have the right setters in the backing object - and I really don't want to put them there - but I don't want the tag to set the values! Is there any way to just set a hidden value somewhere for each row of a datatable but not have it try to set the value? Thanks in advance!

    I just realised that won't work because all the HTML tags will have the same name, whereas I need the dynamically generated suffix that a dataTable assigns to every element in the row i.e. '_id34', so I can reference the value in the javascript and compare it to entered values. Any more ideas? I am having huge memory problems when I'm submitting my form too, using up 2GB of mem and then dying! I'm not sure what's causing it, because it doesn't get as far as my action method code before it dies! It works for smaller tables but I need to be able to handle ~20 users with tables 4x the size I can process now without running out of memory :( Any help would be really really appreciated!!

Maybe you are looking for

  • Questions on the Effects settings

    Well, the next thing that somewhat throws me is the use of the special effects.  For example, when I clicked on the special effects for a particular object it always comes up with Bevel and Emboss and Directional Feather checked.  I typically have to

  • Nokia E65 Software (support pages)

    Hello, I've seen some new applications available for E65 at product pages/support ( http://europe.nokia.com/A4361156 ), Corporate Phonebook and Psiloc Wireless Presenter. As they are provided in the support page, I thought they were complete/free app

  • How to raise an information message in Sales order change second screen(pbo

    Hi Experts,   I need to change data in Sales order header if user entered wrong value while creation of order. If he has not given the correct value then i need to raise one information message on second screen of VA02. How can it possible when enter

  • How to rpad spaces for the below code

    begin dbms_output.put_line(rpad(null,10,' ') ||'b'); end; The output is not appending spaces. I have a requirement to append spaces between columns. Some times the column will be empty. In that case the space is not getting appended.Please let me kno

  • Java newbie & text files

    I want to create a simple program that will read a text file and put it in a variable to use later in the program. I can't figure out how to assign characters from the text file to a variable. Please bear with me, this is my latest attempt: import ja