JEditorPane, href tag jump. How?
Hello folks,
Currently I am working on a system which will display the user manual on a JEditorPane component. The manual's text is retrieved from databases and a html text is created from the text. I use the JEitorPane.setText(html) to display the html. Now the problem is with the tag jump within the html page. The html page is shown as I want it to be. The page has at the begging:
<a name="top"></a>
and at the bottom of it:
BACK TO TOP
So user can click on the "BACK TO TOP" to go back to the top of the page.
The problem is with hyperlinkListener's hyperlinkUpdate method. When I click on the "BACK TO TOP" link on the page, this event handler is called and fillay the "pane.setPage(e.getURL());" part is called. Now e.getURL() returns null. What should I do to get this thing work like I want it to?
void hyperlinkUpdate (HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
JEditorPane pane = (JEditorPane) e.getSource();
if (e instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent evt
= (HTMLFrameHyperlinkEvent)e;
HTMLDocument doc = (HTMLDocument)pane.getDocument();
doc.processHTMLFrameHyperlinkEvent(evt);
} else {
try {
pane.setPage(e.getURL()); // L@@K here!
} catch (IOException ex) {
ex.printStackTrace();
}Thanks,
Yoshi
Try this
best regards
Stas
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.event.*;
public class Test
JFrame frame;
JEditorPane ta;
public static void main(String args[])
new Test();
public Test()
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ta = new JEditorPane();
ta.setEditorKit(new HTMLEditorKit());
ta.setEditable(false);
HyperlinkListener lst=new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) {
String descr=e.getDescription();
if (descr.length()>0) {
descr=descr.substring(1);
HTMLDocument doc=(HTMLDocument)ta.getDocument();
Element text=doc.getElement(descr);
ta.setCaretPosition(text.getStartOffset());
ta.addHyperlinkListener(lst);
ta.setText("<HTML><BODY><A HREF=#100>test</A><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><A href='' ID=100>100</A></BODY></HTML>");
JScrollPane scroll=new JScrollPane(ta);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(scroll,BorderLayout.CENTER);
frame.setSize(300,200);
frame.setVisible(true);
Similar Messages
-
How can I POST data within the same page if I have a A HREF -tag as input?
How can I POST data within the same page if I have a <A HREF>-tag as input? I want the user to click on a line of text (from a database) and then some data should be posted.
you can use like this or call javascript fuction and submit the form
<form method=post action="/mypage">
cnmsdesign.doc
</form> -
How to get a value given to a button in HTML using a href tag
Hi,
In my application I have loaded html content in WebView. In the HTML file i have used a Button to which i have given some value in href tag as
<a href="ButtonClick//testing/mysample">
<input type="button" value="Click me" />
</a>
When i click the button i want to get the string "ButtonClick//testing/mysample" in my app.. But i do not want to use InvokeScript() on my webview.. Could anyone please give me a solution for this?..
Thank you.The only way to interact with HTML content from WebView is using JavaScript. You can do this by invoking such scripts from your C# code (using InvokeScript) or embedding the JavaScript method into the button you are working with.
But you need to know that if you intend to get a return value from your JavaScript code, you would need to use the InvokeScript.
Here's an example of printing the value from your hyperlink without InvokeScript. But note that it only prints the value and can't return the value to your C# code without InvokeScript.
string htmlContent = @"
<html>
<head>
<script type='text/javascript'>
function myFunction()
document.getElementById('myResult').innerHTML = document.getElementById('myLinkConent').href.substring(6); //remove 'about:' from href string
</script>
</head>
<body>
<a id='myLinkConent' href='ButtonClick//testing/mysample'>
</a>
<input type='button' value='Click me' onclick='myFunction()'/>
<p id='myResult'></p>
</body>
</html>";
Let me know if this helps.
Abdulwahab Suleiman -
Can we have a href tags in jsf page
hi all,
I tried inserting a link in jsf page using <a href> tag but when I click it, it is appending the link to contextroot.
For Example:
<f:verbatim>
click here
</f:verbatim>
and when I click on it, I see http://www.google.com is appended to my application url after context root like
http://localhost:9080/Ma/view/India/http://www.google.com
and I get 404 error. how do I do it without having my application url.
Thanks
Ma
Edited by: niki007 on Jan 12, 2009 4:32 PMThis problem can occur if you didn't specify any protocol (http:// or https:// or others) in the link. But your example looks fine. I think that you modified the real code to this example, without being aware that you solved the problem yourself.
At any way, you can also just use h:outputLink to render <a> elements. -
DW is rendering a href tag when i drag image into code field
When i drag an image file into the code view in DW it is
creating an a href tag rather than an IMG SRC= tag. I am using a
virtual dedicated server, for the first time, and i don't know if
it has anything to do with the server settings or with the settings
in DW.
I am also having a second problem when trying to save a html
file to the remote server. If i select "Save file to Remote Server"
i can't link to the page in my browser unless i include ".html" at
the end of the link in the <a href> tag. I should not have to
add the .html at the end of my link in order to go to that page. I
have never had this happen before, but i have never used a virtual
dedicated server before either. Again, not sure if this is related
to the server settings or DW.
Can anyone help me with these 2 issues?
Thanks Alan B> When i drag an image file into the code view in DW it is
creating an a
> href
> tag rather than an IMG SRC= tag. I am using a virtual
dedicated server,
> for the
> first time, and i don't know if it has anything to do
with the server
> settings
> or with the settings in DW.
Starting from a newly created page, please give me the exact
steps to
reproduce this.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"alan-emc" <[email protected]> wrote in
message
news:f1eoc2$39h$[email protected]..
>
>
> When i drag an image file into the code view in DW it is
creating an a
> href
> tag rather than an IMG SRC= tag. I am using a virtual
dedicated server,
> for the
> first time, and i don't know if it has anything to do
with the server
> settings
> or with the settings in DW.
>
> I am also having a second problem when trying to save a
html file to the
> remote server. If i select "Save file to Remote Server"
i can't link to
> the
> page in my browser unless i include ".html" at the end
of the link in the
> <a
> href> tag. I should not have to add the .html at the
end of my link in
> order to
> go to that page. I have never had this happen before,
but i have never
> used a
> virtual dedicated server before either. Again, not sure
if this is related
> to
> the server settings or DW.
>
> Can anyone help me with these 2 issues?
> Thanks Alan B
> -
I lost all my colored tags in OSX - They are not listed when I go to Finder/Preferences/Tags. How can I get them back
Hi, try this...
Bootup holding CMD+r, or the Option/alt key to boot from the Restore partition & use Disk Utility from there to Repair the Disk, then Repair Permissions.
Reboot. -
Tag Cloud - how do I get the #hashtags tags to show in cloud?
I've been playing around and added the Tag Cloud to my site. I have set it to "All users". I would have thought that it would pick up hashtags automatically - is this not the case? It has picked up some tags that I have added to pages (by
going to the Page tab> Tags). How do I get hashtags added?Im also looking an answer to this question,
did you found a solution? -
Syntax for href tag in out.println
Hi,
In the jsp, the table displays document number from the for loop in it.
I'm trying to put a hyperlink using href tag to the document number which is in the value "table.getString("VBELN")"
out.println(var + table.getString("VBELN"));
I do not know the correct syntax or any alternative to acheive the hyperlink for the document numbers displayed in the jsp. One that I tried is
out.println(var + "<a href="">" + table.getString("VBELN") + "</a>");
Appreciate your timely help.
Thanks.Thanks Ashish.
I too had the same problem and so couldn't post my question properly and completely.
I've sent you an e-mail in reply.
I need to pass parameter and open the URL with the parameter and no toolbars.
Looking forward to your earliest possible reply. Thanks again. -
i'm not able to use EL(expression language) in href tag of struts html.
can anybody help me out?Use a 2.4 compliant container and web application
or
use a 2.4 compliant container and a 2.3 compliant web application and specify this in your jsp
<%@page isELIgnored="false"%>Also take a look the discussion in [url http://forum.java.sun.com/thread.jspa?threadID=756032] this thread
ram. -
META TAGS? How do I change meta tags while designing my website in iweb?
META TAGS? How do I change meta tags while designing my website in iweb?
I've designed a new website using iWeb. (I'm a beginner and have never done this before.) I published it to MobileMe. The site is for a volunteer organization, which requires that all pictures and images have text tags. (For this purpose, I assume that's the same as Meta tags.) A rep at the local Apple store clued me into iWebSEO Tool ("SEO"). I used it successfully got all my pictures and images tagged, altho it was hard and took a few hours. This was two months ago. I checked my site earlier this week and all the tags have disappeared. I went back to SEO and all my original work was still there. So I hit re-apply and then saved and republished my site. Still no tags. I have several questions. Is this a regular problem with SEO? Do I have to do all the tags over again? Is there any easier solution? Is Apple going to improve iWeb so this is not a problem in the future? I'll appreciate any help I can get. Thanks.
-
How To Spot A Fake Tag Heuer, How To Spot A Replica Rolex
Greatest Poor Air port Limousine services throughout L . a . can be obtained with a low cost price. The explanation for this is extremely straightforward. L . a . Air-port is probably the many congested air-ports. There are millions of website visitors which appear and vanish from the 9 traveling equipment with the Air port. There is absolutely no paucity of consumers to the car hire companies.
Greatest Poor Air port Limousine services throughout L . a . is created achievable through the cut-throat Limo masters. The actual filled metropolis can be went to by simply business people in company; get togethers must take location in between business people. Funds on this sort of situations is not any dilemma. Every single car hire proprietor really wants to give you the finest services. His or her title and his awesome company’utes title will vacation everywhere when the buyer should go content. Organization giving fair providers along with high quality providers is likely to are able associated with helping once more, consequently finest providers are around for business people.
Since vacationers frequently come towards the metropolis, they will maintain your using the services of associated with autos achievable constantly. Businesses have the ability to take care of the cars throughout working order. The actual drivers are usually paid for well-timed earnings, along with paid for along with good-looking cash. Any time things are running smoothly to the companies, the idea routinely echos for the consumers. This is why we've finest Poor Air port Limousine services throughout L . a ..
Limo companies possess marketed effectively on the web. Every is aware just what the various other business can give towards the consumers, every business efforts to enhance very good holiday packages, finest lower price gives because of their consumers. These lenders take care of the calls for of the consumers, they understand such a specific buyer is seeking, and that's the reason why we've the very best Poor Air port Limousine services throughout L . a ..
Effectively polite drivers, intelligent drivers, well-informed drivers are usually chosen through the limo firms. This type of person deft inside the coping with of the bikers. For the entrepreneur they understand precisely what is necessary. Drivers are very well competent in managing newlywed partners inside their autos. They understand when you ought to method their customers along with beverages along with foods; they understand how you can become very discreet concerning selected issues. These types of positive factors not simply to the car owner with the automobile also for the business overall.
A fantastic drive that knows his or her means about L . a . should be able to give you the finest Poor Air port Limousine services throughout L . a .. The visitor really wants to carry out great deal of taking in the sights, and also a one who can be familar with the spot close to the town is a very good manual. They understand best places to make consumer to get a very good mug of coffee. These people charm the actual visitor making use of their very good expertise in good reputation for selected areas. A properly educated drive can be a benefit to the vacationers. He could be an excellent business, he could be an excellent friend, he could be dependable in each and every means, and the man holds along with your pet the actual genuine reputable files. Shedd Perspectives features each ease and comfort to supply for you to the website visitors. Along with the finest providers given by these types of car hire firms embark on for you to show which.
How To Identify Fake Tag Heuer Watches
How To Size Replica Watches
How To Spot A Fake Breitling
How To Spot A Fake Breitling Watch
How To Spot A Fake Cartier
How To Spot A Fake Mens Rolex
How To Spot A Fake Omega
How To Spot A Fake Omega Watch
How To Spot A Fake Panerai
How To Spot A Fake Replica Rolex Watch
How To Spot A Fake Rolex
How To Spot A Fake Rolex Daytona
How To Spot A Fake Rolex Submariner
How To Spot A Fake Rolex Watch
How To Spot A Fake Tag Heuer
How To Spot A Replica Rolex
How To Spot Fake Breitling Watch
How To Spot Fake Breitling Watches
How To Spot Fake Rolex
How To Spot Fake Rolex WatchesIs the bios screen showing when you start laptop?
-
My third upgrade for Shazam Encore was sucessful, but did not include previous tags.
How or where can i find them. Is there a a way to retrieve all my tags?Me too, also upgraded to IOS 5 last night and all the apps, photos, books have disappeared from the iPod Touch. I can see them in iTunes, but can't figure out how to put them back into/onto the iPod.
I tried the right-click and choosing "restore from back-up" without success, as it had just backed up from the updated iPod without all the stuff on it.
I could use a really simple explanation: how to put the stuff that I can see in iTunes on my Mac, back onto the iPod touch??
And yes, it would be nice if Apple just posted a clear, simple explanation of how to do this . . . I haven't found that yet . . .
thanks, RTE -
How to get the text which was clicked in a A href tag.
I am displaying the names from database in a page as hyperlink. When this hyperlink is clicked I want to display the corresponding address from DB. What the problem is when the link is clicked how to get the name which is clicked. I know only to link to a page using href. Now I want the text which has been clicked. Pls help.
Sorry to interrupt here!
For the code you suggested:
David,
if the target path is "http://localhost/testing.jsp", then
the code would become:
David.
So what would the difference between the code shown above and this code:
David
What is the function for these two symbols: "<<" and ">>"? -
How to call Backing Bean method from href tag in JSF. -- URGENT
Hi guys,
i am new to JSF. i want one option. how to call a backing bean method from href.
I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
If anyone knows pls help me. Its Urgent. If u can, give me the code also.
Suggestions will be appreciated.
Thanks
RajeshYou can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html]. -
How can I send textfield(entered by user) values thru href tag ?
Hi,
I need to send the text field values of that page to servlet thru link.How can get the value in the same page.
And also How can I assign one value to a local variable of jsp from javascript?And also How can I assign one value to a local
variable of jsp from javascript?If I am understanding this question correctly, you need an explanation of how JSP works.
Somebody sends a request to your server and as a result, your JSP runs. It generates HTML, which may include Javascript, and sends that HTML back to the browser where the request came from. At this point the JSP is finished. You can't affect its output any more.
Next the browser receives that HTML, and any Javascript it may include. It renders the HTML and displays it, and it may run some Javascript functions. But those Javascript functions cannot affect the output of the JSP because it already finished.
Maybe you are looking for
-
Creation of new movement type and transaction code
Hi As per my business requirement i want to create new movement type 911 in 1M and how to assign to transaction code MIGO and if possible can some body can guide me with configuration. With regards G Narendra kumar
-
My iphone4 turns off an on every 5 or 10 mins how can i fix this problem
please help its so annoying
-
Can I download ios5 by wifi on my ipad2
Friend having trouble updating ipad2. Has latest version of iTunes continues to get download error. Can we just download ipad2 updates via wifi?
-
Please Help ------SVRMGR -ERROR - ORA-12538
PPL, I am getting "MESSAGE 4505 NOT FOUND,NO MESSAGE FILE FOR PRODUCT=RDBMS,FACILITY=MGR ERROR WHILE TRYING TO RETRIEVE TEXT FOR ERROR ORA-12538" ...Can anyone help me with this ? I cannot connect to SVRMGR from cmd prompt.
-
I am trying to use the Rebean SDK to set the order of prompts in a XI3.1 SP3 Webi document. This document does contain universe prompts, i.e. a table has a self join with @Prompt(). Looking through the Javadocs, I see a PromptOrder class, but it on