HttpUnit- inability to getText

Heya peeps!
Simulating web navigation has been easy till now. For some reason I cant view a particular frame(MainFrame).
all that appears when the getText method is used is this:-
<html>
<head DIR="LTR">
<title>e-point : Web Desktop - Workload</title>
<link rel="stylesheet" type="text/css" href="styles/ePOINT.css">
<link rel="stylesheet" type="text/css" href="styles/ePOINT.css">
<link rel="stylesheet" href="calendar/calendar.css"></link>
</head>
<body topmargin="2" leftmargin="6" marginheight="2" marginwidth="6" bgcolor="#ffffff" link="orange" alink="orange" vlink="orange" leftmargin="0" topmargin="0">
<h2>The script has thrown an exception</h2><[xmp>EXCEPTION:<EXCEPTION><DESC>Unexpected Exception caught in WEBSCRIPT::TRANSFORMLAYOUT:
@null</DESC><CODE>-7</CODE><ORIGIN entry="TRANSFORMLAYOUT" line="0" /></EXCEPTION></xmp>[/b] </body>
</html>
As you can see it says that an unexpected exception was caught in WEBSCRIPT.
My question is where does this error coming from? Does this happen becoz HttpUnit is unable to read the javascript? Can HttpUnit getText if its written in xml?
Any inputs will be greatly appreciated

Pete H --
No, it is not possible to import Excel files with either the xlsx or the the xlsm file extension.  This is simply a limitation of the Import/Export Wizard.  Sorry.  Hope this helps.
Dale A. Howard [MVP]
VP of Educational Services
msProjectExperts
http://www.msprojectexperts.com
http://www.projectserverexperts.com
"We write the books on Project Server"

Similar Messages

  • ADF - MyFaces, HttpUnit testing problem with Javascript.

    Dear all
    Does anybody know how to test ADF Faces. Any tool would be of interest to me although Opensource and Free Software is prefered?
    My task is to write a set of unit tests to test an Oracle ADF and Apache MyFaces application. I have attempted to use both Cactus and HttpUnit. However I am struggling with a simple test case which should simulate a login.
    The problem I have is that ADF Faces produces the following dynamic javascript file (I am guessing it is dynamic because I can not find this in either adf-faces-impl-10_1_3_0_4.jar or adf-faces-api-10_1_3_0_4.jar which are the two jars am implementing in my project.):
    Common10_1_3_0_4.js
    Which when parsed by js.jar (Rhino javascript engine) I get the following error:
    com.meterware.httpunit.ScriptException: Event 'submitForm('maincontent:loginForm',1, {source:'maincontent:submit'});return false;' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "split" of undefined at
    com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptException (JavaScript.java:202)
    (This file Common10_1_3_0_4.js is over 5000 lines long and so I do not want to post it as this posting is already quite long).
    Downloading the file directly after it has been built and modifying it and fixing the error by ensuring the split function is called on a strongly typed String variable, then commenting out from the web.xml below I tried the HttpUnit test again.
         <servlet>
              <servlet-name>resources</servlet-name>
              <servlet-class>oracle.adf.view.faces.webapp.ResourceServlet</servlet-class>
         </servlet>
         <!-- servlet-mapping>
              <servlet-name>resources</servlet-name>
              <url-pattern>/adf/*</url-pattern>
         </servlet-mapping -->
    This time I get no error, but the original login page simply gets served again.
    login.jsp (which is called as login.jsf)
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <!-- Content -->
    <af:objectSeparator />
    <af:panelBox text="#{msg['login.info.loginHeader']}" width="100%" background="transparent">
         <af:form id="loginForm">
                   <af:objectSpacer height="10px" />
                   <af:panelGroup layout="vertical">
                        <af:panelForm labelWidth="5%">
                             <!--User Name-->
                             <af:panelLabelAndMessage for="username">
                                  <af:inputText label="User Name:"
                                       id="username"
                             columns="25"
                             required="yes"
                             secret="false"
                             value="#{userBean.userName}"
                             shortDesc="#{msg['global.user.userName']}" />
                             </af:panelLabelAndMessage>
                             <af:panelLabelAndMessage for="password">
                                  <af:inputText label="Password:"
                                       id="password"
                             columns="25"
                             required="yes"
                             secret="true"
                             value="#{userBean.password}"
                             shortDesc="#{msg['global.user.password']}" />
                             </af:panelLabelAndMessage>
                   <af:objectSpacer height="10px" />
                        <!--Login Button-->
                        <af:commandButton id="submit"
                                  textAndAccessKey="#{msg['global.button.login']}"
                                  action="#{userBean.login}" />
                        </af:panelForm>
                   </af:panelGroup>
         </af:form>
    </af:panelBox>
    TestCase LoginTest.java:
    package com.siemens.pse.wmstesting;
    import java.io.IOException;
    import junit.framework.TestCase;
    import junit.framework.TestSuite;
    import com.meterware.httpunit.GetMethodWebRequest;
    import com.meterware.httpunit.WebConversation;
    import com.meterware.httpunit.WebForm;
    import com.meterware.httpunit.WebLink;
    import com.meterware.httpunit.WebRequest;
    import com.meterware.httpunit.WebResponse;
    public class LoginTest extends TestCase {
         * The URL of the Login page for all login tests
         public static final String URL = new String( "http://localhost/WMS/pages/login.jsf" );
    public static void main( String args[] ) {
    junit.textui.TestRunner.run( suite() );
    public static TestSuite suite() {
    return new TestSuite( LoginTest.class );
    public LoginTest( String s ) {
    super( s );
    public void testGetLogin() throws Exception {
         response = new WebConversation( ).getResponse( request );
    // Test the result
    assertContains( response, "Login Management" );
    public void testLoginSuccess() throws Exception {
         response = new WebConversation( ).getResponse( request );
    WebForm form = response.getFormWithID( "maincontent:loginForm" );
    assertNotNull( "No form found with ID 'maincontent:loginForm'", form );
    form.setParameter( "maincontent:username", "admin" );
    form.setParameter( "maincontent:password", "pass" );
    WebLink submit = response.getLinkWithID("maincontent:submit");
    response = submit.click();
    System.out.println( response.getText());
    // Test the result
    assertContains( response, "Welcome to the Temperature Measurement System" );
    * Convenience function that asserts that a substring can be found in
    * the returned HTTP response body.
    * @param theResponse the response from the server side.
    * @param s the substring to look for
    public void assertContains( WebResponse response, String s ) {
         String target = new String("");
         try {
                   target = response.getText(); }
         catch (IOException e) {
              e.printStackTrace(); }
         if ( target.indexOf( s ) < 0 ) {
              // Error showing which string was NOT found
              fail( "Response did not contain the substring: [" + s + "]" );
    private WebRequest request = new GetMethodWebRequest( LoginTest.URL );
    private WebResponse response;
    }

    Dear All
    Well I found the solution to my testing requirements. HtmlUnit is able to deal with the dynamic Javascript that is generated by the ADF Faces application. The strange part is that HtmlUnit uses the Rhino Javascript engine just as HttpUnit and Cactus, however these two could not deal with the javascript whereas HtmlUnit could.
    I include a snippet of a test case that I wrote that now works.
    public void testLoginSuccess() throws Exception {
    final WebClient webClient = new WebClient( BrowserVersion.INTERNET_EXPLORER_6_0 );
    final URL url = new URL("http://localhost/WMS/pages/login.jsf");
    final HtmlPage page = (HtmlPage)webClient.getPage(url);
    // Get the form that we are dealing with and within that form,
    // find the submit button and the field that we want to change.
    final HtmlForm form = page.getFormByName("maincontent:loginForm");
    final HtmlTextInput usernameField = (HtmlTextInput) form.getInputByName("maincontent:username");
    final HtmlPasswordInput passwordField = (HtmlPasswordInput) form.getInputByName("maincontent assword");
    final ClickableElement button = (ClickableElement) form.getHtmlElementById("maincontent:submit");
    // Change the value of the text field
    usernameField.setValueAttribute("admin");
    passwordField.setValueAttribute("pass");
    // Get the submitted form
    final HtmlPage welcomePage = (HtmlPage) button.click();
    assertEquals( "Temperature Measurement System", welcomePage.getTitleText() );
    }

  • HTTPUnit: submitting an online form in Java

    Hi, I have a problem filling out an online form using the HttpUnit API in Java. I have a java program that opens up an IE browser and goes to the website, but when I try to send the WebRequest, the program gives me a "Connection timed out" error. Not sure what I'm missing here, I have the same coding as many other examples I've found around the web for form validation. Here is my code:
    import com.meterware.httpunit.*;
    import com.meterware.httpunit.cookies.CookieProperties;
    import com.meterware.httpunit.cookies.CookieListener;
    import com.sun.org.apache.xerces.internal.util.URI;
    import java.awt.*;
    import java.net.URL;
    public class expertLogin
    public static void main(String[] args)
    try
    String url = "http://fedexifc.infousa.com/QAA/demo/Login.aspx";
    WebConversation wc = new WebConversation();
    CookieProperties.setDomainMatchingStrict(false);
    CookieProperties.setPathMatchingStrict(false);
    HttpUnitOptions.setExceptionsThrownOnScriptError(false);
    CookieProperties.addCookieListener(new CookieListener()
    public void cookieRejected(String s, int i, String s1)
    System.out.println("CookieProperties.isDomainMatchingStrict() = " + CookieProperties.isDomainMatchingStrict());
    System.out.println("CookieProperties.isPathMatchingStrict() = " + CookieProperties.isPathMatchingStrict());
    System.out.println("s = " + s);
    System.out.println("s1 = " + s1);
    System.out.println("Reason: " + i);
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe \"http://fedexifc.infousa.com/QAA/demo/Login.aspx\"");
    WebRequest req = new GetMethodWebRequest("http://fedexifc.infousa.com/QAA/demo/Login.aspx");
    WebResponse resp = wc.getResponse(req);
    WebForm loginForm = resp.getFormWithName("form1");
    String[] cookies = wc.getCookieNames();
    for (int i = 0; i < cookies.length; i++)
    String cooky = cookies;
    System.out.println(cooky + " = " + wc.getCookieValue(cooky));
    loginForm.setParameter("TextBoxUsername", username");
    loginForm.setParameter("TextBoxPassword", "password");
    loginForm.setParameter("TextBoxGroup", "group");
    loginForm.submit();
    for (int i = 0; i < cookies.length; i++)
    String cooky = cookies[i];
    System.out.println(cooky + " = " + wc.getCookieValue(cooky));
    resp = wc.getCurrentPage();
    System.out.println(resp.getText());
    catch (Exception e)
    e.printStackTrace();

    I'll try this again. I have a problem filling out an online form using the HttpUnit API in Java. I have a java program that opens up an IE browser and goes to the website, but when I try to send the WebRequest, the program gives me a "Connection timed out" error. Not sure what I'm missing here, I have the same coding as many other examples I've found around the web for form validation. Here is my code:
    import com.meterware.httpunit.*;
    import com.meterware.httpunit.cookies.CookieProperties;
    import com.meterware.httpunit.cookies.CookieListener;
    import com.sun.org.apache.xerces.internal.util.URI;
    import java.awt.*;
    import java.net.URL;
    public class expertLogin
    public static void main(String[] args)
    try
    String url = "http://fedexifc.infousa.com/QAA/demo/Login.aspx";
    WebConversation wc = new WebConversation();
    CookieProperties.setDomainMatchingStrict(false);
    CookieProperties.setPathMatchingStrict(false);
    HttpUnitOptions.setExceptionsThrownOnScriptError(false);
    CookieProperties.addCookieListener(new CookieListener()
    public void cookieRejected(String s, int i, String s1)
    System.out.println("CookieProperties.isDomainMatchingStrict() = " + CookieProperties.isDomainMatchingStrict());
    System.out.println("CookieProperties.isPathMatchingStrict() = " + CookieProperties.isPathMatchingStrict());
    System.out.println("s = " + s);
    System.out.println("s1 = " + s1);
    System.out.println("Reason: " + i);
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe \"http://fedexifc.infousa.com/QAA/demo/Login.aspx\"");
    WebRequest req = new GetMethodWebRequest("http://fedexifc.infousa.com/QAA/demo/Login.aspx");
    WebResponse resp = wc.getResponse(req);
    WebForm loginForm = resp.getFormWithName("form1");
    String[] cookies = wc.getCookieNames();
    for (int i = 0; i < cookies.length; i++)
    String cooky = cookies;
    System.out.println(cooky + " = " + wc.getCookieValue(cooky));
    loginForm.setParameter("TextBoxUsername", username");
    loginForm.setParameter("TextBoxPassword", "password");
    loginForm.setParameter("TextBoxGroup", "group");
    loginForm.submit();
    for (int i = 0; i < cookies.length; i++)
    String cooky = cookies[i];
    System.out.println(cooky + " = " + wc.getCookieValue(cooky));
    resp = wc.getCurrentPage();
    System.out.println(resp.getText());
    catch (Exception e)
    e.printStackTrace();
    }{code}
    The error message is:
    {code}
    java.net.ConnectException: Connection timed out: connect
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         ...11 more
    Caused by: java.net.ConnectException: Connection timed out: connect
    ...9 more{code}

  • HttpUnit Testing error

    Hi all,
    HAPPY NEW YEAR to every one.
    i have one problem in HttpUnit, i used below code to login the page, i entered same un and password directly in IE login is working, but in HttpUnit below program not login, another method testContactUs Link click is working properly.
    Thanks,
    import com.meterware.httpunit.*;
    import junit.framework.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import junit.framework.TestCase;
    public class TestHttpUnitTest extends TestCase {
        public static void main(String[] args) {
            junit.textui.TestRunner.run(MainHttpUnitTest.class);
        public TestHttpUnitTest(String name) {
            super(name);
    public static void testLogin() throws Exception {
            WebConversation wc = new WebConversation();
            WebRequest request = new GetMethodWebRequest("http://localhost:7001/project/flow.jx?stateID=start");
            WebResponse response = wc.getResponse(request);
            WebForm loginForm = response.getForms()[0];
            request = loginForm.getRequest();
            request.setParameter("userID", "password");
            request.setParameter("tempID", "tempPASS");
            response = loginForm.submit();
            //response = wc.getResponse(request);
            assertTrue("Login rejected while logging in with 'tempID'",
                    response.getText().indexOf("Invalid Username or Password") != -1);
            String text = response.getText();
            System.out.println("Login Response:" + text);
    public static void testContactUsClick() throws Exception {
            WebConversation wc = new WebConversation(); // create a new web client
            WebResponse response = wc.getResponse( "http://localhost:7001/project/index.html" ); //get the response from Web Server
            response = response.getLinkWith("contact us").click();
            System.out.println("The title of the ContactUs page is: " + response.getTitle());
    }

    So the password is passed to a field named "tempID"? That's odd. The next step might be to make sure your code is grabbing the right form.
    You're doing this:
    WebForm loginForm = response.getForms()[0];Are you sure that is returning the one you think it is? You should do some debugging (using a real debugger to step thru the code and examine things, or use a "poor man's debugger" by simply adding some System.out.println statements in there to let it show you what form the code actually retrieved).

  • Application testing using HttpUnit on SAP netweaver EP

    Hi,
    I'm trying to perform blacbox testing on login page of an application running on SAP netweaver server.
    The code in the testClass looks like this:
    URL serverUrl = new URL(url);
            WebConversation conversation = new WebConversation();
            WebRequest request = new GetMethodWebRequest(serverUrl,"");
            WebResponse response = conversation.getResponse(request);
            assertNotNull("response of url: " + url, response);
    WebForm[] logonform = response.getForms();
    System.out.println("login form."+logonform.length+".");The length parameter above returns 0.
    However when the same Html code for login page is run under IIS server, the length parameter is 2, which is correct.
    Same code running under IIS is fine whereas under Netweaver EP server its not returning correct values.
    Can anyone help on this matter.
    The Html Source for the login page is :
    <table valign="middle" align="center" border="0" cellspacing="0" style="margin-top:10">
      <tr>
        <td colspan="2" valign="Top" width="300" height="24" class="welcome">
          Welcome
        </td>
      </tr>
      <tr>
        <td colspan="2" valign="Top" >
           <table border="1" bordercolordark="#BEBEBE" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" bordercolorlight="#BEBEBE">
         <tr>
               <td style="padding-top:10px; padding-left:10px" align="left" valign="top" bgcolor="E9E9E9" bordercolor="#FFFFFF">
               <!-- data table starts after this line -->
    <FORM name="logonForm" method="post" action="">
    <input name="login_submit" type="hidden" value="on">
        <input type="hidden" name="login_do_redirect" value="1" />
    <input name="no_cert_storing" type="hidden" value="on">
    <table border="0" width="301" height="100" align="left" cellspacing="0" valign="top">
        <!-- display self-registration link if supposed to do so -->
            <tr>
                <td align="left" bgcolor="E9E9E9" colspan=2>
                  <table border="0" cellpadding="0" cellspacing="0" >
                    <tr>
                      <td>
                        <span class="urLblStdBar">New Here?</span>
                        <a class=urLnk href="/irj/servlet/prt/portal/prteventname/redirectNotify/prteventdata/redirectURL!3d!252firj!252fservlet!252fprt!252fportal!252fprtroot!252fcom.sap.portal.navigation.portallauncher.default/prtroot/com.sap.portal.usermanagement.admin.SelfReg">
                          <span class=urTxtStd>Register Now...</span>
                        </a>
                      </td>
                    </tr>
                  </table>
                </td>
            </tr>
        <!-- display error message if there is one -->
            <!-- no error message, display placeholder -->
            <tr>
              <td colspan="2" height="24"></td>
            </tr>
        <!-- userid -->
        <tr>
          <td width="161" height="20">
            <label class=urLblStd for="logonuidfield">
              User ID
              <span class=urLblReq> *</span>
            </label>
          </td>
          <td width="183" height="20">
            <input style="WIDTH: 21ex" class="urEdfTxtEnbl" id="logonuidfield" name="j_user" type="text" value="">
          </td>
        </tr>
        <!-- password -->
        <tr>
          <td width="161" height="20">
            <label class=urLblStd for="logonpassfield">
              Password
              <span class=urLblReq> *</span>
            </label>
          </td>
          <td width="183" height="20">
            <input style="WIDTH: 21ex" class="urEdfTxtEnbl" id="logonpassfield" name="j_password" type="password">
          </td>
        </tr>
        <!-- authentication scheme -->
                <input name="j_authscheme" type="hidden" value="default">
        <!-- space above buttons -->
        <tr>
          <td colspan="2" height="20">  </td>
        </tr>
        <!-- logon button -->
        <tr>
          <td colspan="2">
            <input style="height:3ex;" class="urBtnStd" type="submit" name="uidPasswordLogon" value="Log on">
          </td>
        </tr>
        <!-- link to certificate logon -->
        <!-- logon help -->
            <tr>
                <td align="left" bgcolor="E9E9E9" colspan=2>
                  <table border="0" cellpadding="0" cellspacing="0" >
                    <tr>
                      <td>
                        <span class="urLblStdBar"> Logon Problems?</span>
                          <a class=urLnk href="/irj/servlet/prt/portal/prttarget/uidpwlogon/prteventname/gotoHelpPage/prtroot/com.sap.portal.navigation.portallauncher.default">
                            <span class=urTxtStd>Get Support</span>
                          </a>
                      </td>
                    </tr>
                  </table>
                </td>
            </tr>
    </table>
    </form>
                <!-- data table ends before this line -->
            </td>
            <td bordercolor="#FFFFFF" >
    <table border=0 cellspacing=0 cellpadding=0>
    <tr><td>
    <img src="/logon/layout/branding-image.jpg" alt="Branding Image" border="0"></td>
    </td>
          </tr>
          <tr>
            <td bordercolor="#FFFFFF" >
             <img src="/logon/layout/branding-text.gif" alt="" border="0">
           </td>
          </tr>
         </table>
           </td>
          </tr>
         </table>
        </td>
      </tr>
         <tr>
         <TR>
          <TD border=0 width="100%" align="left">
          <p class="urLblStdBar">� 2002-2004 SAP AG All Rights Reserved.<br>
          <img src="/irj/portalapps/com.sap.portal.runtime.logon/layout/sapLogo.gif" alt="SAP AG" title="SAP AG" width="36" height="18" vspace="3"></p>
          </td>
      </tr>
    </table>
    <!-- after including jsp resource umLogonPage.jsp-->
    <!-- EPCF: BOB BODY -->
    <DIV style="DISPLAY:none">
    <FORM name="DSMSender7fd6ba4208a6c5848735af08fc824465" action="" method="POST" target="" >
    <input type="hidden" name="TermString">
    <input type="hidden" name="SerPropString">
    <input type="hidden" name="SerKeyString">
    <input type="hidden" name="LogoffMode">
    <input type="hidden" name="Autoclose">
    <input type="hidden" name="LogTerm">
    </FORM>Thanks!

    Hi Kishor,
    My code in Httpunit testClass looks like this:
    URL serverUrl = new URL(url);
    WebConversation conversation = new WebConversation();
    WebRequest request = new GetMethodWebRequest(serverUrl,"");
    WebResponse response = conversation.getResponse(request);
    assertNotNull("response of url: " + url, response);
    WebForm[] logonform = response.getForms();
    System.out.println("Get no of forms-->"logonform.length".");
    Here, I want to retrieve the number of forms in the page. I'm getting '0' as the output of "logonform.length" when trying on SAP EP server, whereas I used same html source to create a web page on local machine (windows xp sp 2)and tried to run on local server(IIS), the output is as expected i.e. 2.
    If I try to use WebTable table = response.getTables()[0];
    then the text associated with the table is shown as "iView is not compatible with your browser, operating system or device. Contact your system administrator"
    My IE version is 6.0.
    Is there some problem with the HttpUnit classed I'm using?
    rgds,
    avadh

  • Weird behaviour of getText() ...!!!! PLEASE TAKE A LOOK!!

    Hi.
    my problem is that i have two forms named JF_ChangeAP and DisplayTree. Suppose that JF_ChangeAP has two string variables named XMLFile and ElementDesired... I try to set the value of these two variables from the form DisplayTree(after i've created an JF_ChangeAP object,of course)... Take a look at the following code :
    CODE THAT WORKS:
    ShowAncestorsFrm.XMLFile=this.txtFilePath.getText();
    ShowAncestorsFrm.ElementDesired="Logistics_person";
    CODE THAT DOESN'T WORK:
    ShowAncestorsFrm.XMLFile=this.txtFilePath.getText();
    ShowAncestorsFrm.ElementDesired=this.txtElementDesired.getText();
    (ALTHOUGH I TYPE Logistics_person in the TextField!!!!!)
    I am going crazy...!!!!!!!!!!!!!!!!!!!!!!
    When i debug the value of the ElementDesired in the JF_ChangeAP object is Logistics_person!!!! But it does not work! ! ! ! ! ! ! ! ! ! .......WHY??!?!?!?!?!?!?
    Thnx in advance Guys.!

    your code convetion is arkward..it's hard to tell what is a class and what is an object. you should try not to declar your variable public
    MyClass.myVariable = ""; is not a good idea..and not object oriented (you broke encapsulation)
    since your listing is vague and confussing, i can't really hel you debug your problem. although i'm thinking it's a reference problem..check to make sure you have pass in the correct reference..etc.
    also make sure you created the textfield correctly..
    for example:
    public class Form1 extends JFrame{
        private JTextField textField = new JTextField(10);
        public Form1(){
            JTextField textField = new JTextField(20); 
            // this is wrong..your textfield declared above is not the same one
            // as you add to the frame..so when you call this.textfield.getText(),
            // you are geting the text from the textfield of the instance..not this    
            // local one (which will be displaying in the Frame)
           this.getContentPane.add(textfield);
    }check to make sure the reference to the objects are correct.
    you should redesign your application: here is an example
    public void Form1{
        private JTextField txtFilePath = null;
        private JTextField txtElementDesired = null;
        public Form1(){
            final Form2 = new Form2();
            txtPath = new JTextField();
            txtElementDesired = new JTextField(10);
            JPanel panel1 = new JPanel();
            panel1.add(txtFilePath);
            panel1.add(txtElementDesired);
            JButton = new JButton("Submit");
            button.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    form2.setFilePath(txtFilePath.getText());
                    form2.setElementDesired(txtElementDesired.getText());
            JPanel panel2 = new JPanel();
            panel2.add(button);
            this.getContentPane.add(panel1, "Center");
            this.getContentPane.add(panel2, "Center");
        public String getFilePath(){ return txtFilePath.getText(); }
        public String getElementDesired(){ return txtElementDesired.getText(); }
    public class Form2{
        private String elementDesired = null;
        private String filePath = null;
        public void setFilePath(String filePath){
            this.filePath = filePath;
        public void setElementDesired(String elementDesired){
            this.elementDesired = elementDesired;
    }

  • New to swing: Error while using getText() in ActionPerformed

    Hi there!
    I'm fairly new to java and swing, and this problem I'm having drives me nuts!
    // Imports //
    public class Generator extends JFrame {
         // Graphical components
         private JTextField nr1;
         private JTextField nr2;
         // Constructor
         public Generator() {
              // Call superclass
                    // Init variables
              JTextField nr1 = new JTextField(2);
              JTextField nr2 = new JTextField(2);
              nr1.setVisible(true);
              nr2.setVisible(true);
              // Layout stuff..
              // Create listner-object for event handeling
              Lyssnare minLyssnare = new Lyssnare();
              playerName.addActionListener(minLyssnare);
              clear.addActionListener(minLyssnare);
              shuffle.addActionListener(minLyssnare);
              // closing of window
              // Pack
              // Visible
         // Action Listener
         class Lyssnare implements ActionListener {
              public void actionPerformed(ActionEvent ae) {
                   // Some other actions...
                            // Shuffle
                   else if(ae.getSource() == shuffle) {
                        String teams = nr1.getText();
                        String players = nr2.getText();
                        Shuffle.shuffle(name);
                        playerArea.setVisible(false);
                        int teamsint = Integer.parseInt(teams);
                        int playersint = Integer.parseInt(players);
                        error1.setVisible(true);
         }The error I get is after "else if(ae.getSource() == shuffle) {"
    something on the next line (and the line after that) is the one who gives the error...
    I Get this (during running, compile works fine..):
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    AFAIK that means I'm reffering to something that is null... but how can that be when all the textfields are initialised? do I have to make does fields global in some way?
    Grateful for any help!

    Your inner class does not have access to nr1 and nr2 because they are not final variables.
    Instead of creating an inner class Lyssnare, you can have your Generator class implement the ActionListener and add the actionPerformed method inside Generator class as follows:
    public class Generator extends JFrame implements ActionListener {
         // Graphical components
         private JTextField nr1;
         private JTextField nr2;
         // Constructor
         public Generator() {
              // Call superclass
                    // Init variables
              JTextField nr1 = new JTextField(2);
              JTextField nr2 = new JTextField(2);
              nr1.setVisible(true);
              nr2.setVisible(true);
              // Layout stuff..
              // Create listner-object for event handeling
              //Lyssnare minLyssnare = new Lyssnare();
              playerName.addActionListener(this);
              clear.addActionListener(this);
              shuffle.addActionListener(this);
              // closing of window
              // Pack
              // Visible
    public void actionPerformed(ActionEvent ae) {
                   // Some other actions...
                            // Shuffle
                   else if(ae.getSource() == shuffle) {
                        String teams = nr1.getText();
                        String players = nr2.getText();
                        Shuffle.shuffle(name);
                        playerArea.setVisible(false);
                        int teamsint = Integer.parseInt(teams);
                        int playersint = Integer.parseInt(players);
                        error1.setVisible(true);
              }

  • Printing from MacBook Pro 17" Mid 2010 running 10.8.2 ... persistent inability for Apple MacBook Pro to print to a variety of HP printers (have run Windows and Ubuntu on Parallels and same printers work) ... what is going on with Apple printer support?

    What is wrong with Apple's support of printers ... inability for MacBook Pros to connect with HP and other printers. Yet the same printers
    work under Mac OS based Parallels (running Windows or Ubuntu) - WHY?  Finger pointing (HP . Apple ... Apple > HP) ... who cares ... FIX IT ... this has gone on for months now. WHAT IS THE PROBLEM?

    HP discontinued support (read: stopped updating their OS X printer drivers) for a lot of their printers back when Apple released Snow Leopard and dropped even more when Lion was released.  This is an HP problem, not an Apple problem.
    Exacty what  printers are you having problems with?
    If any of your printers are on the HPIJS list, try installing the HPIJS drivers (there are 3 files to install, and it won't hurt anything).   This solved the issue for me on Snow Leopard, Lion and Mt. Lion with my older HP printers.

  • How to get InputStream from JTextArea.getText() string?

    hello,
    well the postname pretty much says it, i need to get an InputStream for the String of a JTextArea.
    thing is, i want to save the string in a textfile, but the new line isnt recognized when i write it to the file.
    FileWriter fw = new FileWriter ("text.txt");
    fw.write(editField.getText());  // editField is my JTextArea instanceso i thought of doing smth like this
    String lineSeparator = System.getProperty("line.separator");
    // somehow getting the InputStream for my editField and save it in "is"
    BufferedReader br = new BufferedReader(new InputStreamReader (is));
    String line;
    while ((line = br.readLine()) != null) {
    fw.write(line);
    fw.write(lineSeparator);
    }

    pSaiko wrote:
    hello,
    well the postname pretty much says it, i need to get an InputStream for the String of a JTextArea.
    thing is, i want to save the string in a textfile, but the new line isnt recognized when i write it to the file.
    FileWriter fw = new FileWriter ("text.txt");
    fw.write(editField.getText());  // editField is my JTextArea instanceso i thought of doing smth like this
    String lineSeparator = System.getProperty("line.separator");
    // somehow getting the InputStream for my editField and save it in "is"
    BufferedReader br = new BufferedReader(new InputStreamReader (is));
    String line;
    while ((line = br.readLine()) != null) {
    fw.write(line);
    fw.write(lineSeparator);
    This is very simple, it isn't buffered, but it should work for you.
    Sting s = editfield.getText();
    for(int i=0; i<s.length();i++) fw.write((int)s.charAt(i));
    fw.flush();
    fw.close();

  • Photoshop CC 64-bit inability to open more than a single thumnail

    Photoshop CC 64-bit inability to open more than a single thumnail at a time.
    Am I missing a setting in Photoshop CC 64-bit or win 8?

    Some choose not to use Bridge.  I don't care for it myself and don't even have it installed.  With a thumbnailing shell extension installed File Explorer makes a nice integrator.
    From File Explorer, Open With does not appear when multiple files are selected.
    Dragging and dropping to a Photoshop shortcut on the desktop works, as does dragging to the Photoshop Taskbar button and hovering (which brings Photsohop to the front if it's already running) then dropping on the edge of Photoshop.
    -Noel

  • Problem withlight flashing on bottom of computer and inability to turn machine on

    I have a touchsmart IQ800t which I purchased in December of 2008 along with a three year in-house warranty. In April of this year, I was unable to turn my computer on and there was a light blinking from the base of my computer I called customer care. They ran several steps for me to try and when nothing worked, they said I should send my computer in
    for repair. No-one could come to my house as they indicated that it could not be fixed at my house. After they sent me the wrong size box, followed by the right size, I sent it in. This has been done three times and three times it has come back with the problem not fixed. Each time I get lists of things they have done, but I go to turn it on and it doesn't. I still get a flashing light and an inability to turn it on.
     I am very frustrated and could use some sound advice.
    Thank You.

    Wow, you're way more patient than I am. I sent in a (different model) computer because within 24 hours after purchasing it, I got a BSOD. This happened pretty consistently for several days. With my background, it was pretty clear it was either CPU or motherboard problem. Long story short, I sent it in for servicing, it came back with the OS reinstalled (that was fine, expected even) but the check list of what they tested was completely BLANK and no indication that any kind of repair or parts replacement was done. Again, I got a BSOD relatively soon. 
    At that point, I contacted HP support via email again and firmly but politely requested a replacement model and my issue was escalated to a "case manager". And I got my replacement.
    Since your computer is under warranty and if that warranty includes replacement, I would do everything possible to escalate your issue to someone who can make that happen.
    If all else really fails, you could try contacting CEO communication services here: http://www.hp.com/hpinfo/execteam/email/hurd/index.html
    I did this recently regarding some basic but missing functionality regarding the TouchSmart applications; in addition to the standard, mostly automated email assuring me my email had been forwarded to the right people, I also got a follow-up voice mail, giving me a case number and phone number to call if I had any additional concerns.
    Being polite, firm, and on point in all your communications is key.
    Good luck!

  • How to gettext from textarea in a new line when the linewrap option is true

    Hello everyone..
    I wanted to know that how get we get text from the Jtextarea when the linewrap option is set to true..
    for example..
    Lets say my textarea can have 50 chars without any kind of wrap..
    now when the 51 st char is pressed or entered it automatically goes to the next line..
    now i want to get the text from the textarea and display it in the exact fashion as it is in the textarea..
    Please help me out in this case..

    This can help, if not, take a JTextPane. In my program,
    I get all lines (including wrapped ones) with that
    I hope, there are no indexing or so errors, I had to adapt my code
    a bit.
    View root =
    myJTextComponent.getUI().getRootView(myJTextComponent).getView(0);
    int number_of_paragraphs = root.getViewCount();
    int linestart, lineend;
    String line;
    for(int paragraphindex = 0; paragraphindex< number_of_paragraphs;
    paragraphindex++)
         for(int line_in_paragaph = 0; line_in_paragraph <          
         root.getView(paragraphindex).getViewCount(); line_in_paragraph++)
         linestart =   root.getView(paragraphindex).getView(line_in_paragraph).getStartOffset();
         lineend=
         root.getView(paragraphindex).getView(line_in_paragraph).getEndOffset();
            try
            line = myJTextComponent.getDocument().getText(linestart,
            lineend-linestart);
            System.out.println(line);
            catch(BadLocationException e) {...}
    }

  • Need Help with a getText method

    Gday all,
    I need help with a getText method, i need to extract text from a JTextField. Although this text then needs to converted to a double so that i can multiply a number that i have already specified. As you may of guessed that the text i need to extract already will be in a double format.e.g 0.1 or 0.0000004 etc
    Thanks for your help
    ps heres what i have already done its not very good though
    ToBeConverted.getText();
    ( need help here)
    double amount = (and here)
    total = (amount*.621371192);
    Converted.setText("= " + total);

    Double.parseDouble( textField.getText() );

  • I have a problem in the iPhone 4 is an inability to make or receive calls, and must restore the information from iTunes, how do I do this and what is the way?

    I have a problem in the iPhone 4 is an inability to make or receive calls, and must restore the information from iTunes, how do I do this and what is the way?

    iPhone User Guide (For iOS 4.2 and 4.3 Software)

  • Has Apple done anything to address the issue of Mountain Lion's inability to support Epson printers? I have a Stylus Photo RX620 that now is useless. I am not a computer geek so would rather not try to do an uninstall of Mt. Lion and go back to S.Leopard

    Has Apple done anything to address the issue of Mountain Lion's inability to support Epson printers? I have a Stylus Photo RX620 that now is useless. I am not a computer geek so would rather not try to do an uninstall of Mt. Lion and go back to S.Leopard

    Have you tried to open System Preferences, then Print & Scan and then try to Add + a printer?
    I have an Epson RX580 and am using OS X 10.8.2 and it is working as a (Bonjour) printer.  My Epson RX580 is plugged into my AirPort Extreme and I can print over my wireless network to the RX580.  However, I do not see any Scan options with this setup.
    Anyone know anything about getting the scanning portion of the RX580 to work over the network like the printing function does with my Airport Extreme?  Or can I not "share" a scanner over the USB port on the Airport Extreme?  I know, kind on topic/off topic - but I think it fits under OS questions better. 
    Thanks for your advice!
    Randy
    image added by: randynchicago

Maybe you are looking for

  • HP Pavilion DV7-6190ED Windows 7 64-Bit Recovery not working

    Hello, I just bought a new (used as showmodel) laptop at a local store. But I'm having a problem with the recovery now. What happened: When I first booted my laptop and after it started windows, I saw some flickering pixels on the screen. I did some

  • Windows Integrated Security with SSRS, Sharepoint 2013 and SSAS over http

    I have the following setup and problem: Sharepoint 2013 with SSRS in Sharepoint integrated mode SSAS 2012 SP1 with http access (IIS + msmdpump) enabled on the same box as SSAS Every component I have tried works fine with this (PerformancePoint, .bism

  • Trouble with iPhoto 5

    My friend asked me to show her how one take out pictures from iPhoto to another folder. It should have been an easy task, but a darn thing happened. When I selected a number of pictures and draged them to another folder, only one picture appeared. By

  • Javascript and Flash Forms

    I am trying to do some Javascript with a Flash Form and it is failing. I have a field with a value in the field name so I dont have to use labels. I know with Javascript that onFocus, the field will clear. Is that possible in a Flash Form. Don

  • Data Service Auto-Detect Return Type Error

    Hello,   I am not sure if I am posting in the correct area, as this is my first post in a long time.  I have an error when trying to Auto-Detect Return Type for my Web Service Data Service.  The error is 'Data type "Table_type" cannot be merged with