Display a scrolling message that can be updates by another webpage - java

I'm looking for a solution to this and I have searched the web for an answer with nothing. I need a scrolling message on my webpage that can be updated by the same website but on a different page. (e.g www.webpage.com <-- has the scrolling message on it, www.webpage.com/settings <-- has a form in which you can change/update the scrolling message)
I'm pretty sure this is achievable with Java, but my knowledge on Java is slim and all my efforts have come to a fail. I have managed to get a scrolling message on my webpage and I'm sure if I could read a text file (with the message in) then assign that to a 'var', I could make that scroll but I don't know how to do that.
If you know a completely different method of doing this I am happy to change mine.
Thanks in advance,
Tom.

I would recommend javascript instead of java, since java is not really conventional anymore and looks ugly too (and requires a special plugin).
It depends on how fast you want to update the scrolling text how you want to do this. I would say save the text to a .txt or database from settings, and then have your page get it.
You can then use php to read the value from the .txt file or database to display it on your website.
If you want it to be extremely up to date you can let javasript call a little .php file that reads the file and gives you the content.
To make your text scroll you don't really need anything other than html, like so:
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
You can read more about that here: http://www.quackit.com/html/codes/scrolling_text.cfm

Related

I dont understand this output produced by selenium webdriver java

I'm trying to write an application for the game Path of Exile, that lists the items in my stash on trading websites automatically.
For this I have to retrieve the items in my stash from their website. For some reason the ".getText()" functions is behaving very weird on the website. I really can't see any mistakes I did with the x-path Expressions.
Example:
Here you can see a snippet from the HTML file I am working on
screenshot of browser debugg tool
In the screenshot you can see that the x-Path I am using is selecting a element with a text element, however when I iterate over the elements and get the text with the getText() function, it returns a empty String... I really have no clue what I am doing wrong, is it the website, that is denying me to access the field?
In case it helps I add here a screenshot of the source code for outputting the text fields
printing the text of the elements(SourceCode)
5 empty Strings as output
On your place I would try to get value instead of text.
try to replace
e.getText()
with
e.getAttribute("value")
or you can also try to play with .getCssValue()

GWT data display

As a means to display information on a website developed mainly with GWT and EXT-GWT, i am using a HTMLLayoutContainer. So far, the information it is displayed correctly, but it is too harsh or rough to display this way, meaning rough, not nice to see.
So the question is : Is there any other and nicer way to display (print, draw) information with GWT?.
If so, how?
You need to work on CSS
GWT CSS Ref

Anchor not working in IE7 via redirect (spring-mvc, jsp)

So for this project I am doing I have a page which generates content via clickable buttons. The button posts the form to my controller and the controller acts on the button that has been clicked. To show what was changed a redirect will occur (form in the session) with an anchor included. A little piece of javascript will then go to anchor which is in the link (eg. website/add/picture#123). This works fine in pretty much every browser except Internet Explorer 7.. I found out this has to do with an input field of file type.. Because if I remove the input field, then even IE7 will nicely scroll to the anchor..
Does anyone have any idea why this behaviour occurs?
If it's unclear please tell me and I'll provide more details..
Thanks a lot,
Davey
So.. I didn't manage to solve the input type=file bug.. I suppose it's just an IE7 bug. I made a work around to put the input field on a popup. A lot of overhead but it is working pretty well now

Is it possible to count lines of visible text in HTML formatted file?

We have a form that lets people input html formatted text and that input is then displayed elsewhere on the webpage.
Due to layout constraints the input may not be longer than X lines. There is no preview of the edited text in the webpage. Input upon submit is immediately published. (Short Explanation why I cannot fix the layout: the text in question is displayed as an overlay above an image. The overlay has about the size of the image and that is fixed. The text should be completely visible inside that overlay and should not spill over.)
I am being asked to implement something to keep people from entering too much text.
My first try was going for "maxLength" but goes wrong because of the possibility html formatting of the input.
Besides the obvious two 1. expecting users to be smart and/or 2. implementing a preview method, how else could we possibly solve this?
I am out of ideas, I'll also accept an explanation why it is impossible
Technology used: java, wicket 1.4.x
I'm not a web-development expert so this may not be a precise enough answer.
Using javascript you can get the effective size of an HTML element once it has been rendered in the browser. Thus, one solution could be to render the page server-side, and check whether the result exceeds the size you expect.
This may not guarantee a correct result however because the server may render the page differently than the client. You could also always accept the input, then when the client renders the page, have a snippet of javascript that checks (client-side this time) whether the rendered result is okay. If it isn't, then let javascript redirect the client to an error page so that it can edit his input.
What I'd do however is to change the layout so that nothing breaks if the user enters too much text. Using the CSS overflow property could be a start. You could also implement better solutions in javascript such as dynamically changing the text size until it fits the size you want.

How to keep the bottom of an SWT Browser widget visible when appending to the HTML content?

I'm viewing HTML in an SWT Browser widget. I am appending logging messages to the end of the content and would like to keep the bottom visible all the time. Currently, whenever I append text to the content, I first set the new text:
browser.setText(content);
And then I scroll down the Browser widget via JavaScript:
browser.execute("window.scrollTo(0,100000);");
The problem with this is that when I set the text, the widget switches to the top again before scrolling down, so when I append lots of messages quickly, the browser widget is showing the top part most of the time, occasionally flickering when switching to the bottom. This makes it impossible to follow what is being logged at the bottom.
I am aware that I could use a tree viewer and get all the convenience of the Eclipse platform, but there is a Swing version of the app too and both should use the same HTML with CSS presentation.
Ideally I'd like to avoid embedding a Swing component, but if there is one that would allow this, I'd be happy to hear about it. I have tried it with a JEditorPane inside a JScrollPane, appending to the content via the editor kit's read method:
editorPane.getEditorKit().read(/*...*/);
And then scrolling down like this:
editorPane.setCaretPosition(editorPane.getDocument().getLength());
This works very smoothly for the standalone Swing app, but embedded in Eclipse it flickers and does not keep up with fast updates of the HTML content.
Right now the only way I can make this work smoothly inside Eclipse is prepending to the Browser widget's content instead of appending, but I'd really prefer adding new messages at the bottom, not at the top.
Rewriting the whole HTML content every time seems unnecessarily busy-work, and there may not be a way to prevent some browsers from scrolling to the top each time you redraw the entire page. Especially if you allow the logs you show to get very long, this will get slower and slower as the log gets longer.
A better solution might be to use JavaScript to append to the page. You're already using
browser.execute()
How about something like this (assuming "itemID" is the ID of the DIV containing the content):
String newContent = newContent.replaceAll("\n", "<br>").replaceAll("'", "\\\\'");
browser.execute("document.getElementById(\"itemID\").innerHTML += '"
newContent + "'");
You have to do the replaceAll() and you may need a couple more transformations, depending on your log content. I've noticed that browser.execute() doesn't like it if the script contains newlines, for example, and single quotes in your string needed to be quoted as I show above.
I would have just added this as a comment, but it wouldn't let me (not enough reputation). You can ship XUL in a nonstandard location on the mac, by setting a system property.
System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "/fubar/xul/Versions/1.9.0.7/");

Categories