Frequently Asked Questions

Below you will find answers to questions that are frequently asked in our community forums. If you don't find what you are looking for below, then please search the community forums to see if the topic you're intersted in has been brought up before. If you would like to request that additional questions be added to the FAQ, please send an email to community@thinwire.com.

General Questions

How to open multiple views of the same application

The main parts of the underlaying technology are a web browser on the client side and a servlet container on the server side. Servlets can maintain state across many server transactions by using HTTP cookies, session variables or URL rewriting. ThinWire uses the standard servlet cookie JSESSIONID to separate different connections. So the behaviour depends on your operationg system and the used browser.
Most browsers (if not all) share the same JSESSIONID between all windows of the same instance. If you open a new tab or a new window from within your browser and start a ThinWire application with the same URL there that is already in use in another window of the browser then the browser will reuse the old JSESSIONID and ThinWire will be confused and everything will end up with an hanging application or an error.
On windows it should be possible to work around by starting a new browser from the start menu or the command line.
In the combination Debian (maybe on other Linux distributions too) and Iceweasel (=Firefox) also this workaround failed and it was necessary to switch between different logon users via the Gnome (gdm) logoff/change user feature.
If you are not afraid of changing the source (and preparing the web.xml) there is a possible way in this forum thread.

How to push information from server to client / update the UI from another thread?

You have to use a timer task. See this forum thread.

Is it possible to have editors in cells on the GridBox component?

  1. The short answer is: not yet, but planned for in v1.3.
  2. The long answer is: you can mimic similar behavior by using the Grid interface capabilities of TableLayout.
To see an example of this, pull up the Playground Demo and click on the "TableLayout (Grid Interface)" example. The example also provides the source code you need to get started. By using this approach, you can place any component type into a grid cell.

How do you listen for the shutdown of an application instance / session?

Although there are technical reasons nothing yet that lets you customize what the shutdown message looks like or anything that would let you detect the user closing the browser, but you can write code to be notified whenever a users session is terminated as a result of a timeout or as a result of the frame's visibility being set to false elsewhere in the application. See the following forum thread for details.

Is it possible to detect the browser window closing?

No, but you can SIMULATE a similar effect as follows:

  1. Set the session-timeout as low as possible. As far as a I know, the web.xml lets you set the timeout to a minimum of 1 minute. Some application servers may have a workaround for this, but generally 1 minute is sufficient.
  2. Have each application instance register an application timer-task and schedule it to run at an interval that is about 50% of the session-timeout time. So if the session timeout is 1 minute, then set this to 30-second intervals. The body of the timer can be entirely empty, it's just important that it be registered so the browser talks to the server at regular intervals.
  3. Add a "visible" PropertyChangeListener to the Application's Frame and place whatever shutdown code you want to execute upon browser-close in the listener's "propertyChange" method.

That's it. With those three steps you're shutdown code should be run about 1 minute after the browser window is closed. You can read/discuss this topic in this forum thread.

Can I access request parameters, http headers, web.xml init-params or remote user info?

Yes, the String[] arguments that are passed to the main method of the application include the request parameters by default, with each entry in the arguments array containing a value such as "param=value". To access http headers, remote user info, web.xml init-params or context-params, you must first add an additional init param to the application configuragion in web.xml that toggles on the passing of the information you are looking for. For instance, here's a configuration that passes all information to the application:

    <init-param>
      <param-name>extraArguments</param-name>
      <param-value>initParam,contextParam,clientInfo,header</param-value>
    </init-param>

After doing this, the various items will be returned to you in the following formats:

  • HTTP Headers: "HEADER_xxxx=value"
  • Remote Users: "CLIENT_INFO_USER=value", "CLIENT_INFO_HOST=value", "CLIENT_INFO_ADDRESS=value"
  • Additional <init-param> values: "INIT_PARAM_xxxx=value"
  • All <context-param> values: "CONTEXT_PARAM_xxxx=value"

How can I access the servlet container session environment

The bad news: You cannot do directly from within ThinWire.
The good news: There are two mechanism to get around this limitation:

  1. Session varibles via Application.Local:
If your goal is to store per session variables you can do this comfortable via Application.Local from the ThinWire API. Have a look at this forum thread for some discussion and examples.
  1. Full access to HttpServletRequest:
If you need full access, do not call ThinWire directly, but call your own HttpServlet and do whatever you want there (authentification, role management, etc) and delegate afterwards to Thinwire and maybe continue your actions when it returns from the delegate call. In the forums there are some threads with basic code, additional explanation (cross context forward), and web.xml integration.

How to switch to a given TabSheet

tabFolder.setCurrentIndex(tabFolder.getChildren().indexOf(tabSheet))

An extensive design explanation is given in this forum thread.

Tomcat5 permissions

After the default installation of tomcat5 on a Debian Etch box I had to grant the following permissions to the ThinWire application to get it working:
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.util.PropertyPermission "file.encoding", "read";
And some file permissions (permission java.io.FilePermission) which I don't think necessary in general.

Why do I get a "getRootItem() is ambiguous for the type T" error?

This error occurs when you try to build a ThinWire application using Java 5 or later, but you are using a Java 1.4 build of the thinwire.jar. The RC1 and earlier SDK's included the Java 1.4 build of the thinwire.jar as the default. If you want the Java 5 version, you have to download it separately from the Download page. See this thread for more information.

How to include custom JavaScript code in a ThinWire application?

The official way is to use a WebBrowser component and embede your JavaScipt code there.
Thinwire is not designed to use custom JavaScript code elsewhere. Nevertheless - if you know what you do there was a interesting possiblity pointed out in this thread.

Release related problems

Ant build fails (v1.2 RC1)

ant dist fails with something like:
-compile:
[echo] Compiling Java Source
[javac] Compiling 117 source files to [...]/temp
[javac] error: error reading [...]/build.antpp.xml; error in opening zip file
You have to manually exclude some files by changing the classpath of the "-compile" target in build.xml from:
<classpath>
<fileset dir="./" includes="*/**"/>
<fileset dir="${path.library}" includes="*/**"/>
</classpath>
into:
<classpath>
<fileset dir="./" includes="*/**" excludes="**/*.xml,**/*.png,**/*.css"/>
<fileset dir="${path.library}" includes="*/**"/>
</classpath>

For a detailed discussion see this forum thread
This issue should be resolved in revision 333. You can check out the bugfix from the svn repository.

Inherited components not rendered (v1.2 RC1)

There is a known issue with inherited components. See bug tracker 1621380 and 1631639.
This issue should be resolved in revision 286. You can check out the bugfix from the svn repository.




Join our Mailing List

Latest Blog Post

After Countless Fixes and Tweaks, ThinWire v1.2 RC2 is Here! Final is Near!

Latest Build

v1.2 Release Candidate 2

Get The Book

ThinWire Handbook: A Guide to Creating Effective Ajax Applications

Meet The Team

Ajax Experience 2007 San Francisco July 25-27
JavaOne 2007 Startup Exhibitor
AjaxWorld East 2007 Speaker & Exhibitor

Related Links