Friday, August 28, 2009

Render labels correctly with IBM JSF

If you place a jsf component like this on your page:


<h:selectOneRadio disabledClass="selectOneRadio_Disabled"
enabledClass="selectOneRadio_Enabled"
id="selectType"
required="true"
tabindex="11"
value="#{myBean.type}" layout="pageDirection">
<f:selectItems value="#{myBean.selectTypes}" />
</h:selectOneRadio>


You will notice that the labels for the radio buttons in the final html are not generated like you would want them to - the label tag goes around the text and the radio button.

There is a context parameter you can set in the web.xml, so the generation of the html is as expected.


<context-param>
<description>
Set to true to explicitly associate labels with their input elements for select one radio buttons
and select many check box lists.
</description>
<param-name>com.ibm.ws.jsf.associateLabelWithId</param-name>
<param-value>true</param-value>
</context-param>


source : http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rweb_jsf_custom_props.html (new window)

Wednesday, August 12, 2009

"Loading" Modal Div using IBM JSF

An easy way to disable the entire screen (prevent user input) while making an ajax call in ibm's jsf implementation : use a hx:panelDialog with your loading message, and use "show" and "hide" in the behaviorAction of the elements that trigger the ajax requests.

example :


<h:selectOneMenu id="selectTopic" styleClass="selectCombobox" value="#{myBean.topic}">
<f:selectItems value="#{myBean.allTopics}" id="selectTopics"/>
</h:selectOneMenu>
<hx:behavior event="onchange"
target="selectTopic"
behaviorAction="show;get;hide"
targetAction="loading_modaldialog;pgLeafTopic;loading_modaldialog"
id="selectTopicBehavior"></hx:behavior>
<h:panelGroup id="pgLeafTopic">
<h:selectOneMenu id="selectLeafTopic" styleClass="selectCombobox" value="#{myBean.leafTopic}">
<f:selectItems value="#{myBean.leafTopics}" id="selectLeafTopics"/>
</h:selectOneMenu>
</h:panelGroup>
<hx:ajaxRefreshRequest
target="pgLeafTopic"
id="ajaxRefreshRequest2"
params="form1:selectTopic"
>
</hx:ajaxRefreshRequest>
<hx:panelDialog id="loading_modaldialog"
for=""
movable="false"
showTitleBar="false"
saveState="false">
<h:outputText id="loadingdialogtext" value="Loading Data" />
</hx:panelDialog>

This will show and hide the modal div while the leafTopic dropdown gets a refresh depending on the selected topic in the first dropdown.

Wednesday, July 15, 2009

Logging SOAP messages AXIS client

If you want to debug your axis web service client and do not want to alter any code, you can follow this procedure to log all incoming and outgoing soap messages.

make a file with the name client-config.wsdd with this content:

<!--
Save this file as "client-config.wsdd" in the working directory
of your Axis client. Axis will load it automatically. The
configuration here tells Axis to save all incoming and outgoing
XML into a file named "axis.log"
-->

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<handler name="log" type="java:org.apache.axis.handlers.LogHandler" >
<parameter name="LogHandler.fileName" value="c:/logs/soapmessages.log"/>
</handler>

<globalConfiguration>
<requestFlow>
<handler type="log" />
</requestFlow>
<responseFlow>
<handler type="log" />
</responseFlow>
</globalConfiguration>

<transport name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender" />

</deployment>

Dump it in the class root of the application, so the axis loader can pick it up (where you would place log4j.properties for example).

The only downfall is that you cannot dynamically change your logging level. You'll have to remove the file to disable the tracing.

Monday, June 22, 2009

Deploying web application on WAS 6.1 fails, not all jars are in lib folder

When exporting an ear or war file from RAD, and there are backup files like ".#web.xml.1.6" (probably generated by cvs / RAD) in your WEB-INF folder, they get exported as well.

If you try to deploy this ear on your websphere application server (on windows), this succeeds. But those files with the special characters could not be copied. Somehow the copy progress of other jars in your WEB-INF\lib folders halts as well. So not all your jar files are in the lib folder of the deployed project.

Make sure there are no files with special characters (that the windows file system cannot handle) in your ear file.