Getting textbox id of an applet without knowing it - java

I'm having an applet in which the class name is known but the text box fields and other controls and their ids are not known.
Now i need to get the id of the textbox or the total controls exists in the applet from javascript or some java code.

If you're trying to say the text boxes (and whatnot) are part of the Java applet -- these are not HTML elements (although they may look similar), so they are not directly accessible from JavaScript. The applet may provide indirect access to them via LiveConnect, but by default there is no interface provided.

Related

Window, Document vs. $wnd, $doc

I know that the following is some kind of the same in GWT:
Window and $wnd
Document and $doc
Are there any differences, beside that the first is used in Java and the second in JSNI (JavaScript)?
Window is a class plenty of static methods, which you can use for getting or setting certain properties of the browser window, but actually it is not the native browser window object. These method implementations are eventually JSNI blocks which use the $wnd variable to set/get those properties. Like Window.alert() whose implementation would be $wnd.alert(). Note that Window.java doesn't have access for everything in the browser's window object like window.console etc.
GWT uses $wnd instead of window because compiled code is executed normally in an iframe, and in this context, window will reference the iframe window while $wnd will reference the parent window. The same occurs with $doc which is a reference in the iframe to the parent document.
In the other side Document is a java class which extends JavaScriptObject, it means that it is an Overlay type which basically means that it is a special wrapper for a native javascript object, it does not modify the underlying JavaScript but adds a set of java methods to interact with it. It can be safely cast when passing to jsni.
In summary, although Document and $doc are not the same in java world, when it is compiled they will be the same, otherwise Window it's not an overlay of $wnd, it is just a way to access certain methods of the browser window.
Although GWT compiled code delegates to native js objects and methods, don't try to find similarities between js and java objects. GWT has designed an API to develop ajax applications using a set of java objects, widgets, patterns, etc. Some objects and methods are named in the same way, but almost the API is different. There are though, other projects which compiles java to javascript which has a rigid parallelism between both worlds like ST-JS, and GWT provides an experimental library called Elemental whose API is almost identical to javascript (it's only available for Chrome).

Vaadin portlet dynamic language change

I have an Vaadin portlet wich supports "Multilanguage" that means if an user selects for e.g DE in the liferay portal he will get the German translation of some portlets and if he select another language the portlet will be translated to the selected language. there is a problem, the user can translate the portlet only one time , if he selects another language, the portlet keeps the translated strings of the previous language , and the portlet keeps the old language till the portlets init method is reloaded. is there a way to dynamicaly change the language of the portlets components without losing the curret users state(modifications) ?
There is a pattern for Vaadin component translation that may apply here:
Create a utility method to translate Vaadin Component's caption and description properties. Use ThreadLocal-pattern to make that look like a static method or use dependency injection to make it easier call it from everywhere.
In the translating method store the original translation key (string id) to Component.setData()
On dynamic language change call the method to re-translate the component using the Component.getData property. You can easily iterate through the whole visible UI using the ComponentContainer interface starting from the Window.
For storing multiple translation keys into data-property (for the caption and description separately) create your own class or use Map.
Note also that if you have data coming from the database, this pattern does not help and you have to solve that some other way.

Multipage environment in GWT

I have been developing an AJAX web application using GWT. I've read several blogs and forums about this question and left with no clear idea. I understand that GWT is an AJAX application, that supports only stand-alone web application. By stand-alone, I meant GWT to be a single web page that would suffice the user requirements. However the use case I have is pretty complex and I'm stuck in this use case that doesn't let me proceed.
My usecase(s) goes like this:
Usecase #1: There is an order entry form where user will enter a search string to search for a particular item. With GWT, I could display the result in a table (say celltable). However, when I click a column in the cellTable, I want the value of the column to be sent to the server and display another page that will display only the details of the selected column. I'm not sure how to accomplish this.
Usecase #2: Let's say the web application I develop is called "InventoryControl" and I have different requirements such as:
display Available stock
display Order stock
display Manufactured unit
and Using Java servlets, I could just type http://localhost/availableStock?stockId=1234 on my browser to get the "Display available stock" for the given stockId and then http://localhost:orderStock?stockId=1234 to get the "display order stock" and similarly "display manufactured unit". Is the same possible using GWT? i.e. when I type http://localhost/availableStock?stockId=1234, is it possible to read the parameter being passed and then display the corresponding page?
If these are not meant to be guaranteed by GWT, should I stick with Plain old JAVA servlets/JSP?
Thanks in advance.
Ashok - Please note, what filip suggests above does not require multiple "pages" in the sense of additional html host pages. You can build a panel holding your display of the details, and swap it into the rootpanel of your host in the onSuccess() of your rpc call. The GWT history mechanism allows you to assign anchors to these "places" and provide a mechanism to map these anchors to specific display classes in your code.
GWT already has a mechanism for handling multiple page applications. Have a look at Activities and Places. You can define each page as a place in your application, and use the GWT mechanism to go from place to place at any time. Using places also allows you to easily add tokens/query parameters to each "page", in an OO manner, without having to worry about populating/querying the URL directly. Have a good read of the link!

Can we call html ids from Wicket Java class

Is there a way to call ids that are created in html page without specifically giving wicket:id in the component. If so, how can I do that?
What I am trying to accomplish is to get access of the component to assign a default value from CMS. I could assign the default value using JS, however I need that value to be populated to Java so that I could use that in my class to update my business logic depending on the defaulted value.
As I understand it, Wicket is component oriented which means that single component (piece of HTML code) can't see all the HTML. And my guess is that at some late stage, you want to look at the whole page HTML and do something with a DOM node with a specific ID.
I'm not sure what the correct solution should be. One way is to put the value into the user's session, so it's available for each component and your business logic.

Insert JAR into html without Class file

I am trying to put a java program into a HTML page and when launch the page nothing shows up.
How do I call this applet, the only thing I have is a JAR file, I didn't write the program. Thanks all!
edit1: Also I kinda got something going but now it says missing code parameter.
You'll need either a CODE attribute or an OBJECT attribute.
From the Oracle guide to embedding APPLETs:
CODE=< appletFile>
This REQUIRED attribute gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URL of the applet. It cannot be absolute. One of CODE or OBJECT must be present. The value appletFile can be of the form classname.class or of the form packagename.classname.class.
OBJECT=< serializedApplet >
This attribute gives the name of the file that contains a serialized representation of an Applet. The Applet will be deserialized. The init() method will not be invoked; but its start() method will. Attributes valid when the original object was serialized are not restored. Any attributes passed to this APPLET instance will be available to the Applet; we advocate very strong restraint in using this feature. An applet should be stopped before it is serialized. One of CODE or OBJECT must be present.
More, and a tutorial here:
http://download.oracle.com/javase/1.4.2/docs/guide/misc/applet.html

Categories