Using onFocus method with embedded html

Hi,
I have embedded html in a servlet. I am using a text field to call the onFocus method with the following code:
out.println("<input type='text' name='name' value='0' onFocus='if(this.value=='0')this.value=';'>");
If I was using straight html with no servlet this works fine. When the user clicks on the field the default value is automatically erased.
Why will this not work in a servlet?
I have also tried calling a javascript function. Please note that I successfully use javascript with input type 'button' to render a pop up window with dimensions. So my javascript inside a servlet works elsewhere.
Thanks VERY MUCH for your time
Rick

I don't think it's the same as I'm doing. Essentially, I have a JEditorPane subclass, which just has a few custom tags in it. I don't need them to be recognized by java, since it will be uneditable, but I just need to know how to convert from the getText() locations to the actual displayed text locations.
Also, when I set the text as text/html, it creates a bunch of extra HTML tags, so it's larger than the original String used to create it.

Similar Messages

  • Web Intelligence: Save Report as PDF and with embedded HTML code

    Hi all.
    Sorry but I'm not able to find any post about this matter, please feel free to provide links if you know existing topics about this problem.
    We created a beautiful report with HTML5 code embedded into a blank cell and we are now trying to export it in a printable format (e.g.: PDF or HTML).
    As you know (as per manual information) it is not possible to export a report with embedded HTML code and keeping it in the output (cell with embedded HTML code is rendered blank).
    My question is: is there a known workaround or an alternative solution to export the report and keep its content?
    Print screen is not a valid option :-P
    Thanks for the support or any suggestions
    Stecas

    Product limitation; vote for change on ideaplace, etc. I don't believe there is an *easy* workaround, but see:
    https://scn.sap.com/thread/3149287
    HTH
    NMG

  • Why not to use static methods - with example

    Hi Everyone,
    I'd like to continue the below thread about "why not to use static methods"
    Why not to use static methods
    with a concrete example.
    In my small application I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
         public static void wait(int millis){
              r.delay(millis);
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }Do you thinks it is a good solution? How could it be improved? I've seen something about Singleton vs. static methods somewhere. Would it be better to use Singleton?
    Thanks for any comments in advance,
    lemonboston

    maheshguruswamy wrote:
    lemonboston wrote:
    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor and provide a getInstance method to provide lazy initialization.Thanks maheshguruswamy for advising on the steps to create a singleton from this class.
    Could you maybe advise also about why do you say that it would be better to use singleton? What's behind it? Thanks!In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. So a singleton should be enough.But that doesn't answer why he should prefer a singleton instead over a bunch of static methods. Functionally the two are almost identical. In both cases there's only one "thing" on which to call methods--either a single instance of the class, or the class itself.
    To answer the question, the main reason to use a Singleton over a classful of static methods is the same reason the drives a lot of non-static vs. static decisions: Polymorphism.
    If you use a Singleton (and and interface), you can do something like this:
    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();And then whatever is calling KBI's public methods only has to know that it has an implementor of that interface, without caring which concrete class it is, and you can substitute whatever implementation is appropriate in a given context. If you don't need to do that, then the static method approach is probably sufficient.
    There are other reasons that may suggest a Singleton--serialization, persistence, use as a JavaBean pop to mind--but they're less common and less compelling in my experience.
    And finally, if this thing maintains any state between method calls, although you can handle that with static member variables, it's more in keeping with the OO paradigm to make them non-static fields of an instance of that class.

  • Emails with Embedded HTML not coming thru to Mail

    Hi,
    I am running 10.4.10, and I email out a newsletter with Thunderbird 2.0.0.9 so that I can embed an HTML file into it. For 2 days, I have been testing it by emailing to myself from my ISP address to my .mac address, and also to my 3 email addresses that I have thru my ISP (pop account).
    For some reason, the email never arrives in my .Mac box, but it arrives immediately in my 3 pop account boxes and views perfectly. I have used the same security settings since I can remember. I receive iTunes news in my /Mac box (which is embedded HTML right?)
    Why doesn't the email go thru to my .Mac address? I have done this almost monthly for 2 years and have had no problem up til now.
    When I log onto my \Mac web mail, the email is not there either.
    I called my ISP tech support yesterday and the nice guy tried to help, but he wasn't sure how long Apple takes to scan emails containing HTML's. He seemed to think the email could still be enroute but I sent about 14 last night and they astill haven't arrived.
    thanks

    Could Apple have recently increased its security to block unwanted SPAM, and now my computer thinks this email is SPAM?

  • Using JEditorPane.selected() with embedded tags.

    Ok, I've been searching the forums and tutorials for about an hour tonight, and I've seen this question asked in many forms but never answered.
    I am writing an applet which uses embedded HTML and some custom tags in a sub-class of JEditorPane that I wrote. I need to be able to get the position of certain tags within the text, which I can do using the JEditorPane.getText() method. But now that I've found the right tags, how can I highlight text contained within them in the visible Pane?
    e.g.:
    getText() returns
    <html>
    <head>
    </head>
    <body>
    Check</shu_ind> this <shu_dep>out</shu_dep>
    </body>
    </html>
    And these shu tags are the ones I want to use. I can parse the text and grab the right position, but when I select(begin,end), it's off by a lot b/c select() doesn't look at any embedded info.
    What can I do?

    I don't think it's the same as I'm doing. Essentially, I have a JEditorPane subclass, which just has a few custom tags in it. I don't need them to be recognized by java, since it will be uneditable, but I just need to know how to convert from the getText() locations to the actual displayed text locations.
    Also, when I set the text as text/html, it creates a bunch of extra HTML tags, so it's larger than the original String used to create it.

  • How can I set the opening home page of FIrefox to display the current bookmarks. This used to work with bookmarks.html but I understand this file is no longer current.

    I wish to display my current bookmarks as my opening home page in Firefox. I do not wish to use the Bookmarks sidebar instead. It used to work to open with bookmarks.html, which was and still is stored in my Firefox profile. However, I understand this file is no longer kept current but is only retained for legacy/compatibility reasons, and that the current bookmarks info is now stored in places.sqlite, etc. Is there a way with the new versions of Firefox to display as a full opening webpage the assuredly current bookmarks? Thank you

    Hi Jaime,
    Are you saying, you are getting junk characters in the email attachment? Then pls check the following. Since you want to send Japanese fonts, please pass language 'J' in both  objpack-obj_langu = '3' & doc_chng-obj_langu  = '3' instead of '3' please replace it with 'J'.
    Another thing which you may have to check is the SCOT device type. As I understand from my basis colleague, this may also affect your attachment fonts since the emails are sent through SCOT. Go to transaction SCOT-> Settings-> Device types for format conversion. Check whether wrong device type is defined for Japanese there. Hope this helps
    Regards,
    Gokul

  • Problem downloading photo elements 12. got message missing "file archive" using alt method with f# 2

    problem  with download for photo elements 12. got message as I downloaded file 2 (using alt method) that I was miss the "file archive"

    Firstly, there's no such thing as Apache 9.3, there's Apache 1 (and subversions) and Apache 2 (and subversions). Your error message -
    Oracle-HTTP-Server/1.3.28Shows you're using Apache 1.3.28
    Secondly, I'm confused by your comment -
    I do not have Apache 9.3 or higher but I think oracle should offer this in its companion CDOracle does offer the Apache server, if you're saying you didn't get it from Oracle then where did your Apache server come from?
    Thirdly, I notice from your config file -
    ErrorLog "|E:\oracle\product\10.1.0\Companion\Apache\Apache\bin\rotatelogs logs/error_log 43200"That you're piping the logs through rotatelogs, are you sure the logfiles haven't just been renamed?

  • Using equals method with an array?

    Hello all,
    I am attempting to use the equals method with an array and keep getting compiling errors. Could you please take a look at my code and tell me where I am going wrong:
    if(board[row][col].equals(" "))
              str=str + " ";
              else
              str=str + board[row][col];
    Thank you.

    Hello all,
    I am attempting to use the equals method with an
    array and keep getting compiling errors. Could you
    please take a look at my code and tell me where I am
    going wrong:
    if(board[row][col].equals(" "))
              str=str + " ";
              else
              str=str + board[row][col];
    Thank you.If you could post more of your code, that would be quite helpful...

  • Using a method (with paramter) as a value?

    I'm using JSF 1.2 and am trying to accomplish the following:
    Say I have a class, Entity, which has a method:
    public String getResult(String name)
    In my web page, I'd like to loop through some values for name and display each result in a <h:outputText ...>, using things like 'entity.getResult("foo")' in the value attribute, where foo is one of the names in the list I'm looping through.
    Is something like this possible, or would I just be better off building a HashMap or something with the names and results?
    Thanks,
    Matthew

    Isn't an option to collect the data in a List and use the h:dataTable to display them in a table?
    Check http://balusc.xs4all.nl/srv/dev-jep-dat.html how to use datatables.
    Anyway, if this isn't an option, then use f:attribute:
    JSF<h:outputText id="myId" value="#{myBean.text}"><f:attribute name="text" value="blah" /></h:outputText>MyBeanpublic String getText() {
        UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent("myId");
        String text = (String) component.getAttributes().get("text");
        return text;
    }This will show "blah" in the outputText. Of course you can use this to fill in the virtual param of getRequest().

  • How do I use setString() method with multiple bind variables

    I have two setString() statements and a select union statement. My class compiles but only displays the data for the first table ignoring the second setString() statement. But When I replace the "where id=?" with "where id=12 or someid", it works and displays all data found in both tables.
    Am I not properly using the setString() method?
    public class LdData{
    private String id;
    public LdData(){
    public void setId(String id)
        this.id = id;
      public String getId()
        return id;
    public Collection getLdData() throws Exception{
                    List rows = new ArrayList();
    //connection statement
    String sql_query="SELECT a,b FROM table1 WHERE id = ? " + " UNION " + "SELECT a,b FROM table2 WHERE id= ?";
    try {
                            conn = ds.getConnection();
    pstmt = conn.prepareStatement( sql_query );
    pstmt.setString(1, this.id);
    pstmt.setString(2, this.id);
    rst = pstmt.executeQuery();
    while (rst.next()) {
    //dataEntry.java - contains my getter and setter
    dataEntry info = new dataEntry(rst.getString("a"), rst.getString("b"), this.id);
    rows.add(info);
    //catch all SQLexceptions, NamingExceptions
    //close all connection
    return rows;
    //dataEntry.java - dataEntry class
    private String a;
    private String b;
    private String id;
    public dataEntry(String a, String b, String id){
    seta(a);
    setb(b);
    setbdate(bcode);
    this.a = a;
    this.b = b;
    this.id = id;
    public String getA(){
    return a;
    public String getB(){
    return b;
    public String getId(){
    return id;
    public void setA(String a){
    this.a = a;
    public void setB(String b){
    this.b = b;
    public void setId(String id){
    this.id = id;
    //index.jsp - displays data
    <jsp:useBean id="test" class="lddata" scope="request">
    <jsp:setProperty name="test" property="id" param="id"/>
    </jsp:useBean>
    <display:table name="${test.lddata}"/>

    This just doesnt make sense to me at all. :( Could it be a naming issue? I mean both tables have the same field names but different data information
    so the union will never sort and choose. And the weirdest thing is that
    //this works -
    ->String sql_query="SELECT a,b FROM table1 WHERE id = TU234 " + " UNION ALL" + "SELECT a,b FROM table2 WHERE id= TU234";
    //I also tried this, but the second statement doesnt work
    ->pstmt.setString(1, "TU234"); //this works.
    ->pstmt.setString(2, "TU234"); //this doesnt
    //It also tried this, it worked for both set statements, but I need it in an list or so.
    while (rst.next()) {
    String a = rst.getString(a);
    String b = rst.getString(b);
    String id = rst.getString(id);
    System.out.println(a+""+b+""+id);
    }Is there anyother way I can collect the data into a jsp page without using javabean?

  • Calling a method with a html Submit button

    hi guys,
    is it possible to call a method from a JSP file using a HTML submit button. I know i can call another website easily doing it this way, is there a similar way available to call a method once the button is clicked?
    FYI
    The method is in a bean file named jdbc. The methods name is getUsername.
    Nice one.
    <form action = <%jdbc.getUsername()%> <input type="submit" value="Submit">

    Dear friend,
    you mentioned that u need to call a method when submit button is clicked. Is the method dynamically created. If not so, then you can include the method on the submit button html file itself.
    Regards,
    Rengaraj.R

  • PDF printing with embedded HTML

    Hi all.... I am running Apex 4.0.2.00.07 on 10.2.0.4.
    I have a report that looks beautiful on a web page
    it's in in an interactive report with a 2 level grouping
    the data is 4 columns
    image, html table, image, html table
    The image is not stored in the database, it's in an images folder that I use the following code to display
    <pre>
    <img class="mainimage" src="/images/112045_cha.jpg" border=0>
    </pre>
    As for the class, that's in a css at the top
    <pre>
    <STYLE TYPE="text/css">
    .mainimage {
    max-width: 200px;
    max-height: 200px;
    width: expression(this.width > 200 ? "200px" : true);
    height: expression(this.height > 200 ? "200px" : true);
    </STYLE>
    </pre>
    When i look at it in the report, it looks nice, but my requirement is a need to print it.
    If i just print it from the browser, my rows don't line up at page breaks.
    If I export to HTML, my images don't retain the css tag and are too big (also the breaks are not honored)
    If I export to PDF, the breaks are not honored and the HTML is displayed (the img tags and the table displaying the data).
    I have FOP configured, BI Publisher is not an option due to budget.
    Anyone have any suggestions?

    Check this link,
    http://www.obinotes.com/2010/10/how-to-disable-html-tags-within-pdf-in.html
    You can use portalpagenav function and refrence the target report in the column data format instead of go url.
    Thanks,
    Vino

  • Can't use inherited method with JButton

    I am trying to use the getActionListeners() method on a JButton. The method is inherited from the AbstractButton class. However, when I try to compile with this line...
    ActionListener CurrentListeners[] = OKButton.getActionListeners();I get the following error:
    Method getActionListeners() not found in class javax.swing.JButton.
    I am also using the removeActionListener() method, which is inherited from the same object, and the compiler has no problem with that!

    Okay, then does anyone know how I can change the
    ActionListener for a JButton? I want to use the
    removeActionListener(ActionListener l) method and then
    addActionListener(...). However, since I can't get
    the current ActionListener, I have nothing to pass
    into the remove method.It's my belief that's this is why this method was added to AbstractButton in JDK 1.4. It makes life so much easier. Why don't you download the JDK 1.4 and install it into your IDE?
    Otherwise, you should subclass JButton as someone else suggested and provide an accessor method for the listener.

  • Problem with embedded HTML

    Hello,
    I am trying to create a website where I can stream a live video feed to that is coming from a VCR. I am using the media stream segementer to segment the video into the required .ts files as well as the index .m3u8 file. I pulled some example HTML code offline from someone who is doing the exact same project.
    In iWeb 2008 I added an HTML snippet directly in the middle of the page and pasted the example code I got offline into the body of the snippet. I then did a "publish to folder" and put the webpage into a folder that has the following path: /Library/WebServer/Documents/Site/. I then had the media segmenter put the .ts and .m3u8 files into a folder with the following path /Library/WebServer/Documents/Site/stream. I also published the site under the address http://127.0.0.1.
    This is the HTML I pasted into the snippet:
    <html>
    <head>
    <title>My Sample Movie</title>
    <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
    </head>
    <body style="background-color:#FFFFFF; ">
    <center>
    <video src="stream/prog_index.m3u8" controls autoplay ></video>
    </center>
    </body>
    </html>
    The problem arises when I try and play the stream from Safari. All I can see on the webbrowser is a toolbar that displays the play button and says "loading..." but the video stream is never found and played.
    Does anyone know how to fix this problem?
    Thank you in advance!
    -Jason

    "Tell me Winston," said O'Brien, "how many dots do you see?"
    To quote myself :
    3 (THREE) ../../../ before stream
    and
    <video src="../../../stream/prog_index.m3u8" controls autoplay ></video>
    To quote my blog :
    When using relative pathnames to files on your webserver, count three (3) directories down the path: src="../../../iFrame/ifleeg.html" to escape from the iWeb site folder.

  • Cannot use Create method with SODataEntity in iOS Native Apps connect to SMP 3.0 SP05

    Hi experts,
    I am following these blogs:Mobile Application Development Platform for Developers - Native Apps. They are very helpful, thanks Kenichi.
    But i have some error when i use Integration gateway.
    First, i try method Read, it works perfectly. Then, i try to use method Create, and i meet an error. Here is the error :
    Error Domain=NetworkDomain Code=4 "HTTP Response: 403 forbidden" UserInfo=0x7f86d2688040 {NSLocalizedDescription=HTTP Response: 403 forbidden}
    I test CRUD method in REST client, and it runs without any errors. I think the difference between Create and Read method is "X-CSRF-Token": Fetch with Read and specific Token with Create. But i do not know how to supply or config "X-CSRF-Token" field when use SOData...
    Thanks and Reagrads,
    Sao Vu.

    Hi Sao,
    Is your problem solved?
    If not, below code may be able to help you for creation using ODataStore:
    MAFLogonRegistrationData *data = [[MyLogonHandler shared].logonManager registrationDataWithError:&error];
        NSString *baseURL = [NSString stringWithFormat:@"%@", data.applicationEndpointURL];
        //opening the store
        self.onlineStore = [[OnlineStore alloc] initWithURL:[NSURL URLWithString:baseURL]
                                    httpConversationManager:[MyLogonHandler shared].conversationManager];
        [self.onlineStore openStoreWithCompletion:^(BOOL success) {
    //Read request after the store is successfully opened
            SODataRequestParamSingleDefault* readRequest = [[SODataRequestParamSingleDefault alloc] initWithMode:SODataRequestModeRead resourcePath:@"CollectionName"];
            [self.onlineStore scheduleRequest:readRequest delegate:self];
            NSString *finishedSubscription = [NSString stringWithFormat:@"com.sap.sdk.request.delegate.finished.%@",  readRequest];
    //Going for create once read request is success
            [[NSNotificationCenter defaultCenter] addObserverForName:finishedSubscription object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
    //Creating request for posting the data
    SODataRequestParamSingleDefault* insertRequest = [[SODataRequestParamSingleDefault alloc] initWithMode:SODataRequestModeCreate resourcePath:@"CollectionName"];
                insertRequest.payload = entityForCreation; //Assigning the payload
                [self.onlineStore scheduleCreateEntity:entityForCreation collectionPath:@"Collection
    Name" delegate:self options:nil];
    //Alternatively you can use [self.onlineStore scheduleRequest:insertRequest delegate:self]; also instead of scheduleCreateEntity
    If you want to pass X-CSRF-Token with RequestBuilder, you can use the following code:
    //Create request for getting the token
          id<Requesting> request = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:endPoint_URL]]];
            /*Set user name */
            [request setUsername:[[NSUserDefaults standardUserDefaults] objectForKey:@"USERNAME"]];
            /*Set password */
            [request setPassword:[[NSUserDefaults standardUserDefaults] objectForKey:@"PASSWORD"]];
            /*Set the required request headers*/
            [request setRequestMethod:@"GET"];
            [odp_Request addRequestHeader:@"X-CSRF-Token" value:@"Fetch"];
            [odp_Request addRequestHeader:@"X-CSRF-Cookie" value:@"Fetch"];
            [request addRequestHeader:@"Content-Type" value:@"application/xml; charset=UTF-8"];
            [request addRequestHeader:@"X-SMP-APPCID" value:applicationConnectionID]];
            [request addRequestHeader:@"X-SUP-APPCID" value:applicationConnectionID]];
            /*Set the delegate to receive the response */
            [request setDelegate:self];
            /*Set the success listener */
            [request setDidFinishSelector:@selector(tokenSuccess:)];
            /*Set the failure listener */
            [request setDidFailSelector:@selector(tokenFailed:)];
            /*Invoke the startAsyncronous API to send the request from client to server asynchronously */
            [request startSynchronous];
    //In the tokenSuccess method (- (void)tokenSuccess:(Request*)theRequest), you can use the following code to retrieve the token:
          token=[[theRequest responseHeaders]objectForKey:@"X-CSRF-TOKEN"];
           cookie=[[theRequest responseHeaders]objectForKey:@"SET-COOKIE"];
    //Create the request for posting your content to the server
                NSString* requestUrls = [NSString stringWithFormat:@"%@SalesOrders%@", endPoint_URL,filterString];  
                postRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:requestUrls]];
                //             odp_Request = [ODPRequest requestWithURL:[NSURL URLWithString:requestUrls]];
                //id<SDMRequesting> request = [SDMRequestBuilder requestWithURL:[NSURL URLWithString: requestUrls]];
                [postRequest setUsername:[[NSUserDefaults standardUserDefaults] objectForKey:@"USERNAME"]];
                [postRequest setPassword:[[NSUserDefaults standardUserDefaults] objectForKey:@"PASSWORD"]];
                [postRequest setDelegate:self];
                [postRequest setRequestMethod:@"POST"];
                [postRequest addRequestHeader:@"content-type" value:@"application/atom+xml;type=entry"];
                [postRequest addRequestHeader:@"X-SMP-APPCID" value:applicationConnectionID]]; //Assinging the applicationConnectionID value to the request
                [postRequest addRequestHeader:@"X-CSRF-Token" value:token]; //Assinging the token value to the request
                [postRequest addRequestHeader:@"Cookie" value:cookie]; //Assinging the cookie value to the request
                [postRequest appendPostData:[xml dataUsingEncoding:NSUTF8StringEncoding]]; //Appending the body of the request
                [postRequest setDidFailSelector:@selector(updaterequestFailed:)]; //Failure delegate method
                [postRequest setDidFinishSelector:@selector(updaterequestFinished:)];  //Success delegate method
                [postRequest setTimeOutSeconds:200]; //Timeout for request
                [postRequest startSynchronous];
    Hope this will help you.
    Regards,
    Dhani

Maybe you are looking for