<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[ToolTwist]]></title>
		<link>http://www.tooltwist.com/forums/index.php</link>
		<description><![CDATA[The most recent topics at ToolTwist.]]></description>
		<lastBuildDate>Tue, 31 Aug 2010 13:55:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA["package does not exist" error]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=108&amp;action=new</link>
			<description><![CDATA[<p>In the construction phase of deploying to a server, an error like this occurred:</p><div class="codebox"><pre><code>acme_t.jar:
     [echo] Creating acme_t.jar
...
    [javac] Compiling 44 source files to /Controller/launchpads/rpconlgen/tmp/rpconlgen_t-20100824.1/build
    [javac] Compiling 163 source files to /Controller/launchpads/cbapg/tmp/rp-bsg-20100831/build
    [javac] /Controller/launchpads/pad1/tmp/acme-20100831/src/com/acme/JsonRequest.java:3: package com.google.gson does not exist
    [javac] import com.google.gson.JsonArray;
    [javac]                       ^</code></pre></div><p>The Java class compiled correctly in the ToolTwist workbench (Eclipse) but got this error when building in the Controller.</p><p>The most common cause for this type of error is a missing JAR file. To ensure that a JAR file is included when the payload is built by the Controller, it must be placed in the <em>WebContent/WEB-INF/lib</em> folder for the project.</p><p>In this case, the error above was corrected by installing <em>WebContent/WEB-INF/lib/gson-1.5.jar</em> in the acme_t project in Eclipse, and then submitting a new acme_t payload to the Controller. Using the new version of the acme_t payload, the build completed.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Tue, 31 Aug 2010 13:55:24 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=108&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Editing the Navpoint File from Eclipse]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=107&amp;action=new</link>
			<description><![CDATA[<p>Note: In normal situations, there is no need to edit the navpoint definition files - the navpoint screen in the Designer should be used. If for some reason it does need to be edited, make sure you restart the server immediately after making the changes of they may be overwritten.</p><p>If the navpoints file is edited directly from within Eclipse, the navpoint hierarchy might disappear when the server is restarted.</p><p>If this occurs, the most common reason is that the encoding for the file is incorrect. To check this, right click on the file in the designer (e.g. webdesign/config/wbd/navpoints/acme/navpoints.conf) and select properties. On the Resource tab, you&#039;ll see a section titled &quot;Text file encoding&quot;. The correct value for this is UTF-16.</p><p>If it&#039;s incorrect, change it then save the file again, then restart the server.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Sat, 28 Aug 2010 10:52:28 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=107&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[NotSerializableException while restarting]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=106&amp;action=new</link>
			<description><![CDATA[<p>From Leo Aguimatang:</p><p>I always encounter this error in eclipse console when I update a widget and restart the tomcat server:<br /></p><div class="codebox"><pre><code>SEVERE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.dinaa.ui.UimDataStoredInSession
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.dinaa.ui.UimDataStoredInSession
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.Hashtable.readObject(Hashtable.java:859)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    ...</code></pre></div><p>Afterwards the wbd IDE would not open. Its not that critical nor urgent because there&#039;s a workaround by restarting the tomcat server.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Fri, 27 Aug 2010 05:46:49 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=106&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Tomcat Connection Pooling in Tooltwist]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=105&amp;action=new</link>
			<description><![CDATA[<p>Applications are penalized when they try to create new connections to a database.&nbsp; But if an application keeps a connection as long as it can use it, the database may soon run out of connections.&nbsp; A workaround is to keep a pool of open connections.&nbsp; When the application needs to connect to the database, it checks the pool for a connection.&nbsp; When the application is finished with the connection it returns the connection to the pool.&nbsp; The connection pooling library has many responsibilities.&nbsp; It should determine the number of active connections to keep, it should know when to create and destroy connections, etc.&nbsp; Writing one for an application will take considerable effort.&nbsp; Luckily, tomcat provides a built-in connection pooling library.&nbsp; Here are the steps to use it.</p><p>1. Create a file named context.xml under WebContent/META-INF.&nbsp; This file should contain the connection settings to the database.&nbsp; An example is given below:<br /></p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;Context path=&quot;/ttsvr&quot; docBase=&quot;ttsvr&quot; crossContext=&quot;true&quot; reloadable=&quot;true&quot; debug=&quot;1&quot;&gt;

    &lt;Resource name=&quot;jdbc/postgres&quot;
            auth=&quot;Container&quot;
            type=&quot;javax.sql.DataSource&quot;
            driverClassName=&quot;org.postgresql.Driver&quot;
            url=&quot;jdbc:postgresql://10.1.1.153:5432/qvas_coc&quot;
            username=&quot;postgres&quot;
            password=&quot;vsc&quot;
            maxActive=&quot;10&quot;
            maxIdle=&quot;5&quot;
            maxWait=&quot;-1&quot;
            removeAbandoned=&quot;true&quot;
            removeAbandonedTimeout=&quot;60&quot;
            logAbandoned=&quot;true&quot;
            /&gt;

&lt;/Context&gt;</code></pre></div><p>2. Get a datasource from the connection pool.&nbsp; The example below shows how to get a datasource for a jndi resource named: jdbc/postgres.<br /></p><div class="codebox"><pre><code>    InitialContext initialContext = new InitialContext();
    if (initialContext == null) {
        String message = &quot;InitialContext was not setup properly.&quot;;
        logger.error(message);
        throw new SQLException(message);
    }
    // actual jndi name is &quot;jdbc/postgres&quot;
    DataSource datasource = (DataSource) initialContext.lookup( &quot;java:/comp/env/jdbc/postgres&quot; );
    if ( datasource == null ) {
        String message = &quot;WebApp resource was not setup properly.&quot;;
        logger.error(message);
        throw new SQLException(message);
    }</code></pre></div><p>3. Get a connection from the datasource<br /></p><div class="codebox"><pre><code>    Connection con = datasource.getConnection();</code></pre></div><p>For the QVAS project a utility class named JdbcUtil was created.&nbsp; This class is used in XPC&#039;s to get a connection from the pool.<br /></p><div class="codebox"><pre><code>public class JdbcUtil {
    private static DataSource datasource = null;
    private static Logger logger = Logger.getLogger(JdbcUtil.class);

    private synchronized static DataSource getDataSource() throws NamingException, SQLException {
        if (datasource == null) {
            InitialContext initialContext = new InitialContext();
            if (initialContext == null) {
                String message = &quot;InitialContext was not setup properly.&quot;;
                logger.error(message);
                throw new SQLException(message);
            }
            // actual jndi name is &quot;jdbc/postgres&quot;
            datasource = (DataSource) initialContext.lookup( &quot;java:/comp/env/jdbc/postgres&quot; );
            if ( datasource == null ) {
                String message = &quot;WebApp resource was not setup properly.&quot;;
                logger.error(message);
                throw new SQLException(message);
            }
        }
        return datasource;
    }
    
    public synchronized static Connection getConnection() throws SQLException, NamingException {
        return getDataSource().getConnection();
    }

    public static synchronized void freeConnection(Connection connection) throws SQLException {
        connection.close();
    }
}</code></pre></div><p>Usage:<br /></p><div class="codebox"><pre><code>    Connection con = JdbcUtil.getConnection();
    Statement stm = con.createStatement();
    ResultSet rst = stm.executeQuery(sql);</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (theo.reyes)]]></author>
			<pubDate>Fri, 16 Jul 2010 03:56:47 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=105&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Widget Events]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=104&amp;action=new</link>
			<description><![CDATA[<p>From Rezvie F. Navallo:</p><p>I have found that when you put document.observe(&#039;dom:loaded&#039;, function() {}) such as autocompleter from the widget, on tooltwist designer you can&#039;t move that widget out of the page into the basket.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Thu, 08 Jul 2010 04:44:49 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=104&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Using FindBugs in Tooltwist]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=103&amp;action=new</link>
			<description><![CDATA[<p>FindBugs is an eclipse plugin that reviews code and checks for common java coding errors.&nbsp; The errors range from un-removed &quot;TODO&quot; comments; to inefficiency in the code; to possible masking of potential bugs.</p><h5>To install FindBugs:</h5><p>1. Click on Help &gt; Install New Software...<br />2. Click on Add...<br />3. Fill in the following:<br />&nbsp; &nbsp; - Name: FindBugs<br />&nbsp; &nbsp; - Location: <a href="http://findbugs.cs.umd.edu/eclipse/">http://findbugs.cs.umd.edu/eclipse/</a><br />4. Check FindBugs and the packages underneath it<br />5. Continue the installation process by clicking on Next, I Agree, etc..</p><h5>To use FindBugs</h5><p>1. Right-Click on the project<br />2. Select Find Bugs &gt; Find Bugs<br />3. The Find Bugs perspective gives a list of possible bugs with suggestions</p><h5>Here&#039;s a list of common bugs found by Find Bugs on the Tutuki project and suggested actions:</h5><p>1. When concatinating strings, especially within a loop, use StringBuffer instead of String<br />&nbsp; &nbsp; wrong way:<br /></p><div class="codebox"><pre><code>        String s = &quot;----\n&quot;;
        for (int i = 0; i &lt; 10; i++) {
            s += &quot;hello\n&quot;;
        }
        System.out.println(s);</code></pre></div><p>&nbsp; &nbsp; correct way:<br /></p><div class="codebox"><pre><code>        StringBuffer s = new StringBuffer(&quot;----\n&quot;);
        for (int i = 0; i &lt; 10; i++) {
            s.append(&quot;hello\n&quot;);
        }
        System.out.println(s.toString());</code></pre></div><p>&nbsp; &nbsp; note: StringBuffer does not override the equals(Object) method.&nbsp; Use the equals method of String by:<br /></p><div class="codebox"><pre><code>        StringBuffer sb = new StringBuffer(&quot;hello&quot;);
        if (&quot;hello&quot;.equals(sb.toString())) ...</code></pre></div><p>&nbsp; &nbsp; or:<br /></p><div class="codebox"><pre><code>        if (sb.toString().equals(&quot;hello&quot;)) ...</code></pre></div><p>2. Avoid empty catch blocks<br />&nbsp; &nbsp; wrong way:<br /></p><div class="codebox"><pre><code>        catch (Exception ex) {}</code></pre></div><p>&nbsp; &nbsp; note: at the very least, do an ex.printStackTrace();&nbsp; This is still not recommended though.&nbsp; Best is to re-raise an exception.&nbsp; Let tooltwist/tomcat/java handle that for you.<br />&nbsp; &nbsp; best way:<br /></p><div class="codebox"><pre><code>        catch (Exception ex) {
            // few handling/logging statements
            throw new CustomException(ex);
        }</code></pre></div><p>3. Handle specific exceptions explicitly.<br />&nbsp; &nbsp; wrong way:<br /></p><div class="codebox"><pre><code>        catch (Exception ex)</code></pre></div><p>&nbsp; &nbsp; right way:<br /></p><div class="codebox"><pre><code>        catch (ExType1 ex) {
            ...
        }
        catch (ExType2 ex) {
            ...
        }</code></pre></div><p>&nbsp; &nbsp; According to FindBugs: &quot;this construct also accidentally catches RuntimeException as well, masking potential bugs.&quot;</p><p>4. When a variable is not in use, delete it.&nbsp; If you think the code will use this later, just comment it out.&nbsp; The bulk of the errors/warnings was because of advance code.&nbsp; One particular sample is the log4j logger.</p><p>5. Misc:<br />&nbsp; &nbsp; - Always remove autogenerated comments.&nbsp; These are comments marked with the text &#039;TODO Auto-generated&#039;.<br />&nbsp; &nbsp; - Always remove unused imports.&nbsp; An eclipse shortcut is to press Command-Shift-&#039;O&#039; to organize imports.</p>]]></description>
			<author><![CDATA[dummy@example.com (theo.reyes)]]></author>
			<pubDate>Thu, 17 Jun 2010 07:40:51 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=103&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Using Page Data]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=102&amp;action=new</link>
			<description><![CDATA[<p>Page Data is data related to a navpoint, that effects the way a widget is displayed.</p><p><strong>Background</strong><br />Quite commonly, multiple navpoints will refer to a single page layout. That doesn&#039;t make much sense if every page was rendered the same, so there are several mechanisms widgets can use to change their appearance, based upon the navpoint being rendered.</p><p>The first, is that the widget looks at one or more of the properties of the navpoint currently being rendered. For example, the navpoint ID, it&#039;s categories, it&#039;s title, or it&#039;s SEO related fields.</p><p>The second, more common way for a widget to change it&#039;s appearance - based upon the navpoint of the page - is to use <em>page data</em>.</p><p>Page data is XML data related to a specific widget, for a specific navpoint. If a widget defines that it wants to use page data, then any navpoint that refers to a page containing that widget will have the &quot;Edit Page Data&quot; button enabled. By clicking on that button, a user can then enter XML that will be used by the widget when it is rendering on that navpoint.</p><p>Note: In a future version, specific page data editors will be available. For now however, page data is all edited as XML.</p><p><strong>Using Page Data in a Widget</strong><br />To use page data, a widget controller must first implement the <em>UsesPageData</em> interface.</p><div class="codebox"><pre><code>public class BillboardWidget extends WbdWidgetController implements UsesPageData
{

    @Override
    protected void init(WbdWidget instance) throws WbdException
    {
        instance.defineProperty(new WbdStringProperty(&quot;pageDataSection&quot;, null, &quot;PageDataSection&quot;, &quot;billboard&quot;));
        ...
    }

    ...
    
    public XData getInitialPageData(WbdWidget instance)
    {
        StringBuffer xml = new StringBuffer();
        xml.append(&quot;&lt;pageData&gt;\n&quot;);
        xml.append(&quot;    &lt;billboard&gt;\n&quot;);
        xml.append(&quot;        &lt;cropImage&gt;cropImageName&lt;/cropImage&gt;\n&quot;);
        xml.append(&quot;        &lt;imageSrc&gt;imageUrl&lt;/imageSrc&gt;\n&quot;);
        xml.append(&quot;        &lt;alt&gt;Alternate text&lt;/alt&gt;\n&quot;);
        xml.append(&quot;        &lt;navPointId&gt;[navPointId]&lt;/navPointId&gt;\n&quot;);
        xml.append(&quot;        &lt;url&gt;[url]&lt;/url&gt;\n&quot;);
        xml.append(&quot;    &lt;/billboard&gt;\n&quot;);
        xml.append(&quot;&lt;/pageData&gt;&quot;);     
        return new XData(xml);
    }

}</code></pre></div><br /><p>This will enable the &quot;Edit Page Data&quot; button for navpoints where this widget is used, and will provide default XML page data. The &quot;PageDataSection&quot; property is used by the page data editor to allow a unique block of XML to be edited for this widget.</p><p>The final step is to have the widget use the page data as it is rendering production pages.</p><div class="codebox"><pre><code>    @Override
    public void renderForJSP(WbdGenerator generator, WbdWidget instance, UimHelper ud, WbdRenderHelper buf) throws Exception
    {
        String navpointId = WbdSession.getNavpointId(ud.getCredentials());
        String pageDataSection = instance.getProperty(generator, &quot;pageDataSection&quot;);

        // Get the page data
        Xpc xpc = ud.getXpc();
        xpc.start(&quot;tooltwist.wbd.getPagedata&quot;, &quot;select&quot;);
        xpc.attrib(&quot;pageDataNavPoint&quot;, navpointId);
        xpc.attrib(&quot;pageDataSection&quot;, pageDataSection);
        XData pagedata = xpc.run();

        // Render the widget, using the page data
        String imageSrc = pagedata.getText(&quot;/*/*/imageSrc&quot;);
        ...
    }</code></pre></div><p>-oOo-</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Wed, 09 Jun 2010 08:01:43 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=102&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Generic Widget Controller]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=101&amp;action=new</link>
			<description><![CDATA[<p>There is now a Generic Widget controller, that can be used in many cases where simple widget functionality is required:</p><p>1. Output from a snippet.<br />2. Zero or more basic parameters, that may be substituted into the output from the snippet.<br />3. No logic.</p><p>Many user controls just require specific HTML or JSP output without any intelligence, except perhaps basic parameter replacement.</p><p>The following steps can be used to crete a new widget without any Java coding. In this example, we&#039;ll just create a page heading surrounded by <strong>h1</strong> tags.</p><p><strong>Step 1: Create a new widget directory</strong><br />Create a new folder for a scratch version of the widget, for the your usual user id.</p><div class="codebox"><pre><code>e.g.
mkdir ...../webdesign/config/wbd/libraries/myProject_widgets/headingWidget/scratch_myUserId</code></pre></div><p><strong>Step 2: Create the configuration file</strong></p><p>In the folder just created, create a new configuration file for the widget (conf.xml).<br /></p><div class="codebox"><pre><code>&lt;widget&gt;
  &lt;widgetClass&gt;tooltwist.wbd.widgets.GenericWidgetController&lt;/widgetClass&gt;
  &lt;idWithinRootWidget&gt;0&lt;/idWithinRootWidget&gt;
  &lt;label&gt;Heading Widget&lt;/label&gt;
  &lt;icon&gt;/tooltwist/wbd/toolbox_icons/youtube_icon.png&lt;/icon&gt;
  &lt;isStatic&gt;Y&lt;/isStatic&gt;
  &lt;description&gt;A heading surrounded by h1 tags&lt;/description&gt;
  &lt;property&gt;
    &lt;name&gt;heading&lt;/name&gt;
    &lt;label&gt;Heading&lt;/label&gt;
    &lt;type&gt;string&lt;/type&gt;
  &lt;/property&gt;
&lt;/widget&gt;</code></pre></div><p>The property tag defines a property that can be edited in the normal manner within the ToolTwist designer.</p><p><strong>Step 3: Create the snippet files</strong><br />Create files named <em>snippet_design.html</em>, <em>snippet_preview.html</em> and <em>snippet_production.jsp</em>. These may be edited with a regular HTML or JSP editor. The parameters defined in the conf.xml will all be available as normal snippet variables.</p><div class="codebox"><pre><code>&lt;html&gt;
&lt;body&gt;
&lt;!--START--&gt;
&lt;h1&gt;%%label%%&lt;/h1&gt;
&lt;!--END--&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre></div><br /><p><strong>Step 4: Restart the server</strong><br />After restarting, the widget should be available to be dropped on a page.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Tue, 08 Jun 2010 16:01:01 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=101&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Excessive log entries from httpclient]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=100&amp;action=new</link>
			<description><![CDATA[<p>By default, the httpclient package writes large amounts of information to the log file. To prevent this, the following lines can be added to log4j.conf.</p><div class="codebox"><pre><code># Print only messages of level INFO or above in the package org.apache.
log4j.logger.org.apache=INFO
log4j.logger.org.apache.commons.httpclient=INFO
log4j.logger.httpclient.wire=INFO</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Wed, 14 Apr 2010 15:00:07 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=100&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Exceptions in an widget's init() function]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=99&amp;action=new</link>
			<description><![CDATA[<p>The init() function is only called once, the first time the widget object is created, which is either (a) when the widget&#039;s configuration is loaded from it&#039;s conf.xml file, or (b) when you drop the widget onto a page.</p><p>In most cases, it is called during (a), when all the widgets are loaded, the first time someone goes into the Designer. If an error occurs here, it&#039;s not always easy to see. The exception is written to the log file, but ToolTwist silently traps the error to prevent a rogue widget from stopping the Designer from running. In most cases, nobody notices the exception till some time later, which can waste a lot of debugging time.</p><p>Another common problem, is if an exception in init() prevents the widget from ever working, until such time as it&#039;s reloaded from file. The widget fails every time it is asked to render itself, but the real error may have occurred a long time previously.</p><p>A better solution is to ensure that errors repeatedly occur, or are at least reported, whenever the widget is displayed in the Designer and also when the JSP pages are being generated.</p><p>A common problem occurs when the widget&#039;s init() cannot find a configuration file.<br /></p><div class="codebox"><pre><code>private XYZ config = null;

public void init()
{
    //  Load the configuration (i.e. stuff that might cause an exception)
    this.config = new XYZ(...);
}

public void renderForJSP(...)
{
    config.getValue();
}</code></pre></div><p>If the config is not sucessfully loaded when init() is called, then renderForJSP() will always have a problem, either:<br />&nbsp; &nbsp; - with a NullPointerException because config is null, or<br />&nbsp; &nbsp; - because config has not been completely initialised, and contains invalid data.</p><br /><p>A better design framework allows the widget to repeatedly trying to load the configuration until it succeeds.<br /></p><div class="codebox"><pre><code>private XYZ config = null;

private XYZ getConfig() throws WbdException
{
    if (config == null)
    {
        syncronized (this)
        {
            //  Load the configuration
            XYZ tmpConfig = new XYZ(...);

            // Do other stuff that might cause an exception
            ...

            // Final step
            this.config = tmpConfig;
        }
    }
}

public void init()
{
    // Don&#039;t load the config
}

public void renderForJSP(...)
{
    String value = config.getSomeConfigurationValue();
}</code></pre></div><p>A few notes:<br />1. The config is not loaded until it is needed.<br />2. An exception in getConfig gets passed back to renderForJSP, and out through to the ToolTwist infrastructure,<br />so it can be included in ToolTwist&#039;s error reports.<br />3. The config variable is only set as the final step - after any chance of an exception occurring. this ensures that<br />the widget will try to load the config again if it fails.<br />4. The &quot;synchronised&quot; prevents the unlikely chance of a concurrency problem with multiple people using the Designer.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Sat, 03 Apr 2010 05:19:03 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=99&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Cookie Handling (Login & Logout)]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=98&amp;action=new</link>
			<description><![CDATA[<p>1. When the user logs in and his credentials have been validated, put a cookie in the users browser indicating that he has logged in.&nbsp; For example.</p><div class="codebox"><pre><code>Cookie cookie = new Cookie(&quot;is_login&quot;, &quot;true&quot;);
cookie.setPath(WbdCache.getWebappPrefix());
response.addCookie(cookie);</code></pre></div><p>2. Aside from the cookie, you need to add a flag in the request object, so that if you have a Production Helper that will be checking for the login status before the current process has returned to the user&#039;s browser, your Production Helper will get the correct value.</p><p>LoginRequestHandler:<br /></p><div class="codebox"><pre><code>WbdSession.setTemporaryValue(uh.getCredentials(), &quot;loginStatus&quot;, &quot;true&quot;);</code></pre></div><p>LoginProductionHelper:<br /></p><div class="codebox"><pre><code>String isLoginTempStr = WbdSession.getTemporaryValue(ud.getCredentials(), &quot;loginStatus&quot;);</code></pre></div><p>If you placed the login cookie in the HttpServletResponse object and the page goes through the Login Production Helper, the production helper won&#039;t be able to find the cookie from the HttpServletRequest object since it is independent from the HttpServletResponse object.&nbsp; It needs to make a full cycle to the user&#039;s browser before the cookie is placed in the request object.</p><p>3. When logging out remove the cookie by expiring it and again set the login flag in the request object to false for the production helper.</p><div class="codebox"><pre><code>Cookie[] cookies = request.getCookies();
for (Cookie c : cookies) {
    if (c.getName().equals(&quot;is_login&quot;)) {
    c.setMaxAge(0);
    response.addCookie(c);
    break;
    }
}
WbdSession.setTemporaryValue(uh.getCredentials(), &quot;loginStatus&quot;, &quot;false&quot;);</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (leo.dosdos)]]></author>
			<pubDate>Thu, 25 Mar 2010 01:55:49 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=98&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Customizing configuration files]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=97&amp;action=new</link>
			<description><![CDATA[<p>The default configuration files used for a server, and also for the launchpad server used to generate it&#039;s files, can be overridden by creating alternate launchpad-specific template files.</p><p>For a server that will be deployed from the Controller, the config files are copied as follows:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_tooltwist.conf-phil_tmp<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; ~<em>servername</em>/server/tooltwist.conf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_wdb.conf<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; ~<em>servername</em>/server/files/webdesign/config/wbd/wbd.conf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_web.xml<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; ~<em>servername</em>/server/tomcat/webapps/ttsvr/WEB-INF/web.xml</p><p>Similar files can be used to override the config files for the launchpad. These might be needed to rectify errors while generating the CI web pages:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_tooltwist.conf-phil_tmp<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; /Controller/launchpads/phil_tmp/image/tooltwist.conf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_wdb.conf<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; /Controller/launchpads/phil_tmp/image/files/webdesign/config/wbd/wbd.conf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; /Controller/custom-config-files/p_web.xml<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt; /Controller/launchpads/phil_tmp/image/tomcat/webapps/ttsvr/WEB-INF/web.xml)</p><p>These files all provide some variable substitution, and are best copied initially from the directory named /Controller/custom-config-files/examples.</p><p>Commonly, these files are modifed for these purposes:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; web.xml - to define servlets<br />&nbsp; &nbsp; &nbsp; &nbsp; tooltwist.conf - to define database connection URLs, and to define technology layers<br />&nbsp; &nbsp; &nbsp; &nbsp; wbd.conf - to define application specific parameters, and parameters for the ToolTwist Designer.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Thu, 18 Mar 2010 15:10:51 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=97&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Manually deploying]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=96&amp;action=new</link>
			<description><![CDATA[<p>The various steps to deploy to a server can be run manually, via a set of generated Ant scripts. Normally these are triggered by the Hudson build task for the launchpad, but they can also be run from the command line.</p><p>The first step is to log on to the controller and go to the launchpad directory. e.g.</p><p>&nbsp; &nbsp; ssh controller2@10.1.1.154&nbsp; &nbsp; &nbsp; &nbsp; (harrier)<br />&nbsp; &nbsp; cd /Controller/launchpads/phil_tmp</p><p>A normal build can be run with the following command:</p><p>&nbsp; &nbsp; ant -f bootstrap.xml</p><p>This is the command that is normally run by the Hudson build task for the launchpad. Note that this only runs steps it decided are necessary, after comparing the launchpad&#039;s configuration files against timestamp files found in the launchpad directory.</p><p>To force the build to start at a specific step, you can remove one or more timestamp files:</p><p>&nbsp; &nbsp; construct.timestamp<br />&nbsp; &nbsp; validate.timestamp<br />&nbsp; &nbsp; generate.timestamp<br />&nbsp; &nbsp; install.timestamp</p><p>The stage for the file you remove will be performed, and subsequent stages as well. Prior stages will also occur if bootstrap.xml determines that they are required. For example, removing generate.timestamp will ensure that a generate and then an install are performed. However, if one of the payloads used by the launchpad have changed, then construct, validate, generate and installed will be performed.</p><p>Steps can be run independantly using the follwoing commands:</p><p>&nbsp; &nbsp; ant - f construct.xml full&nbsp; &nbsp; (stop the server, build everything, start the server)<br />&nbsp; &nbsp; ant - f construct.xml start&nbsp; &nbsp; (start the launchpad server)<br />&nbsp; &nbsp; ant - f construct.xml stop<br />&nbsp; &nbsp; ant - f construct.xml build<br />&nbsp; &nbsp; ant - f generate.xml&nbsp; &nbsp; &nbsp; &nbsp; (generate JSP files for navpoints, crop images, install stylesheets, etc)<br />&nbsp; &nbsp; ant - f install.xml&nbsp; &nbsp; &nbsp; &nbsp; (e.g. install files to phil_tmp@kingfisher)</p><p>Note however, that the status of the launchpad, as shown in the Control Panel, is not updated by these commands.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Thu, 18 Mar 2010 15:00:33 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=96&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Basic Approach to Problem Solving]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=95&amp;action=new</link>
			<description><![CDATA[<p>A few tips for working out the cause of a problem on a Controller-installed server.</p><p>The following information assumes that the website worked properly when generated on the Designer (which may have been run from within Eclipse). In this case, the best approach is to work forwards from the start:</p><p>1. Look at the Tomcat log on the deployed server.</p><p>&nbsp; &nbsp; &nbsp; ~/server/tomcat/logs/catalina.out</p><p>2. Check the deployment occured properly? The Hudson build log can be accessed from the Launchpad&#039;s status page.</p><p>3. Try a complete re-deploy (construct, validate, generate, install), and see if it solves the problem.</p><p>4. Test to see if the same problem occurs on the launchpad.<br />&nbsp; &nbsp; &nbsp; a) go into the designer on the launchpad.<br />&nbsp; &nbsp; &nbsp; b) generate on the launchpad, from the designer, then check that the site works properly.</p><p>5. Assuming it works on the Launchpad server.... check if the configuration files are different. Customised versions of web.xml, wbd.conf, and tooltwist.conf are defined in /Controller/custom-config-files.</p><p>6. Check the version of Java in use on the Controller and the deployed server.</p><p>7. Check the database can be accessed on the deployed server.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Thu, 18 Mar 2010 14:47:22 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=95&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Only a type can be imported. com.abc.XyzClass resolves to a package.]]></title>
			<link>http://www.tooltwist.com/forums/viewtopic.php?id=94&amp;action=new</link>
			<description><![CDATA[<p>This error message can sometimes be displayed in the tomcat log file on a server that is installed by the ToolTwist Controller. What it is indicating, is that a JSP file is referring to a Java class that it cannot find.</p><p>Their are several reasons this can occur:</p><p>1.&nbsp; The design for a new web page has been deployed to the server, but a matching technology payload has not also been deployed. A typical scenario is this:</p><p>&nbsp; &nbsp; &nbsp; - a new widget is been developed and is checked in with technology payload A.<br />&nbsp; &nbsp; &nbsp; - a page uses that widget, and is submitted.<br />&nbsp; &nbsp; &nbsp; - the new page is mapped to the production server (possibly via an &quot;auto&quot; payload), but the new technology<br />&nbsp; &nbsp; &nbsp; &nbsp; payload is not.</p><p>Solution: ensure that a new technology payload is deployed, before any pages that use it&#039;s new widgets/classes.</p><p>2. MOST COMMON. A new technology payload is mapped onto the server. The Controller then installs new JSPs and new JAR files to the server, but the server has not been rebooted. As a result, the new JAR is not recognised by Tomcat.</p><p>Solution: Restart Tomcat.</p>]]></description>
			<author><![CDATA[dummy@example.com (philcal)]]></author>
			<pubDate>Thu, 18 Mar 2010 14:29:37 +0000</pubDate>
			<guid>http://www.tooltwist.com/forums/viewtopic.php?id=94&amp;action=new</guid>
		</item>
	</channel>
</rss>
