Index: seam
===================================================================
--- seam	(revision 9230)
+++ seam	(revision 9405)
@@ -1,16 +1,17 @@
 #!/bin/sh
-############################################
-#
-# seam-gen - Seam project and code generator
-#
-############################################
 
+##############################################
+#                                            #
+# seam-gen - Seam project and code generator #
+#                                            #
+############################################ #
+
 # Validate the JDK installation
 if [ -z "$JAVA_HOME" ]; then
     echo "The JAVA_HOME environment variable is not set"
-    echo "Please point it to a valid JDK installation"
+    echo "Please point it to a JDK installation"
     exit 1
-elif [ ! -x "$JAVA_HOME"/bin/javac ]; then 
+elif [ ! -x "$JAVA_HOME/bin/javac" ]; then 
     echo "The JAVA_HOME environment variable should point to a JDK, not a JRE"
     exit 1
 fi
@@ -32,12 +33,11 @@
 fi
 
 SEAM_GEN_DIR="$SEAM_HOME/seam-gen"
-SEAM_COMMAND="${1}"
+SEAM_COMMAND="$1"
 
-echo "Location of seam script: $SEAM_HOME"
-echo "seam-gen template folder: $SEAM_GEN_DIR"
+echo "SEAM_HOME: $SEAM_HOME"
+echo "Using seam-gen sources from: $SEAM_GEN_DIR"
 
-# OS specific support (must be 'true' or 'false').
 cygwin=false;
 case "`uname`" in
     CYGWIN*)
@@ -50,7 +50,12 @@
 elif [ "$SEAM_COMMAND" = help ]; then
     cat "$SEAM_GEN_DIR/README"
 elif $cygwin; then
-   java -cp "${JAVA_HOME}\lib\tools.jar;${SEAM_HOME}\build\lib\ant-launcher.jar;${SEAM_HOME}\build\lib\ant-nodeps.jar;${SEAM_HOME}\build\lib\ant.jar" -Dant.home="${SEAM_HOME}\lib" org.apache.tools.ant.launch.Launcher -buildfile "${SEAM_GEN_DIR}\build.xml" -Dworking.dir="$WORKING_DIR" ${*}
+    # Must pass real Windows paths to Java (Java doesn't execute in the context of cgywin)
+    JAVA_HOME_WINPATH=`cygpath -aw "$JAVA_HOME"`
+    SEAM_HOME_WINPATH=`cygpath -aw "$SEAM_HOME"`
+    SEAM_GEN_DIR_WINPATH=`cygpath -aw "$SEAM_GEN_DIR"`
+    WORKING_DIR_WINPATH=`cygpath -aw "$WORKING_DIR"`
+    "$JAVA_HOME/bin/java" -cp "$JAVA_HOME_WINPATH\lib\tools.jar;$SEAM_HOME_WINPATH\build\lib\ant-launcher.jar;$SEAM_HOME_WINPATH\build\lib\ant-nodeps.jar;$SEAM_HOME_WINPATH\build\lib\ant.jar" -Dant.home="$SEAM_HOME_WINPATH\lib" org.apache.tools.ant.launch.Launcher -buildfile "$SEAM_GEN_DIR_WINPATH\build.xml" -Dworking.dir="$WORKING_DIR_WINPATH" "$@"
 else
-   java -cp "${JAVA_HOME}/lib/tools.jar:${SEAM_HOME}/build/lib/ant-launcher.jar:${SEAM_HOME}/build/lib/ant-nodeps.jar:${SEAM_HOME}/build/lib/ant.jar" -Dant.home="${SEAM_HOME}/lib" org.apache.tools.ant.launch.Launcher -buildfile "${SEAM_GEN_DIR}/build.xml" -Dworking.dir="$WORKING_DIR" ${*}
+    "$JAVA_HOME/bin/java" -cp "$JAVA_HOME/lib/tools.jar:$SEAM_HOME/build/lib/ant-launcher.jar:$SEAM_HOME/build/lib/ant-nodeps.jar:$SEAM_HOME/build/lib/ant.jar" -Dant.home="$SEAM_HOME/lib" org.apache.tools.ant.launch.Launcher -buildfile "$SEAM_GEN_DIR/build.xml" -Dworking.dir="$WORKING_DIR" "$@"
 fi
Index: seam.bat
===================================================================
--- seam.bat	(revision 9245)
+++ seam.bat	(revision 9405)
@@ -1,41 +1,63 @@
 @echo off
-@if not "%ECHO%" == ""  echo %ECHO%
-@if "%OS%" == "Windows_NT"  setlocal
+@if "%OS%" == "Windows_NT" setlocal
 
+rem ##############################################
+rem #                                            #
+rem # seam-gen - Seam project and code generator #
+rem #                                            #
+rem ##############################################
+
 set WORKING_DIR=%CD%
-set SEAM_DIR=%~dp0
-if "%SEAM_DIR:~-1%" == "\" set SEAM_DIR=%SEAM_DIR:~0,-1%
-set SEAM_GEN_DIR=%SEAM_DIR%\seam-gen
+if "%WORKING_DIR:~-1%" == "\" (
+    set WORKING_DIR=%WORKING_DIR:~0,-1%
+)
+
+if ["%SEAM_HOME%"] == [""] (
+    set SEAM_HOME=%~dp0
+) else (
+    if not exist "%SEAM_HOME\seam.bat" (goto noseam)
+)
+if "%SEAM_HOME:~-1%" == "\" (
+    set SEAM_HOME=%SEAM_HOME:~0,-1%
+)
+
+set SEAM_GEN_DIR=%SEAM_HOME%\seam-gen
 set COMMAND=%1%
-set ARGS=%*
 
 if [%COMMAND%] == [] (goto usage)
 
 if %COMMAND% == help (goto help)
 
-if ["%JAVA_HOME%"] == [] (goto nojava)
+if ["%JAVA_HOME%"] == [""] (goto nojava)
 
 if not exist "%JAVA_HOME%\bin\javac.exe" (goto nojdk)
 
-java -cp "%JAVA_HOME%\lib\tools.jar;%SEAM_DIR%\build\lib\ant-launcher.jar;%SEAM_DIR%\build\lib\ant-nodeps.jar;%SEAM_DIR%\build\lib\ant.jar" -Dant.home="%SEAM_DIR%\lib" org.apache.tools.ant.launch.Launcher -buildfile "%SEAM_GEN_DIR%\build.xml" -Dworking.dir=%WORKING_DIR% %ARGS%
+echo SEAM_HOME: %SEAM_HOME%
+echo Using seam-gen sources from: %SEAM_GEN_DIR%
 
+"%JAVA_HOME%\bin\java" -cp "%JAVA_HOME%\lib\tools.jar;%SEAM_HOME%\build\lib\ant-launcher.jar;%SEAM_HOME%\build\lib\ant-nodeps.jar;%SEAM_HOME%\build\lib\ant.jar" -Dant.home="%SEAM_HOME%\lib" org.apache.tools.ant.launch.Launcher -buildfile "%SEAM_GEN_DIR%\build.xml" -Dworking.dir="%WORKING_DIR%" %*
+
 goto END_NO_PAUSE
 
 :nojava
 echo The JAVA_HOME environment variable is not set
-echo Please point it to a valid JDK installation
+echo Please point it to a JDK installation
 goto END_NO_PAUSE
 
 :nojdk
 echo The JAVA_HOME environment variable should point to a JDK, not a JRE
 goto END_NO_PAUSE
 
+:noseam
+echo The SEAM_HOME environment variable should point to a Seam distribution
+goto END_NO_PAUSE
+
 :usage
-more %SEAM_GEN_DIR%\USAGE
+more "%SEAM_GEN_DIR%\USAGE"
 goto END_NO_PAUSE
 
 :help
-more %SEAM_GEN_DIR%\README
+more "%SEAM_GEN_DIR%\README"
 goto END_NO_PAUSE
 
-:END_NO_PAUSE
\ No newline at end of file
+:END_NO_PAUSE
Index: seam-gen/view/view.xhtml.ftl
===================================================================
--- seam-gen/view/view.xhtml.ftl	(revision 9374)
+++ seam-gen/view/view.xhtml.ftl	(revision 9402)
@@ -97,7 +97,7 @@
 <#else>
             <h:column>
                 <f:facet name="header">${label(parentProperty.name)} ${label(parentParentPojo.identifierProperty.name)?uncap_first}</f:facet>
-                <@outputValue property=parentParentPojo.indentifierProperty expression="${'#'}{_${parentName}.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}" indent=16/>
+                <@outputValue property=parentParentPojo.identifierProperty expression="${'#'}{_${parentName}.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}" indent=16/>
             </h:column>
 </#if>
 </#if>
Index: seam-gen/view/edit.xhtml.ftl
===================================================================
--- seam-gen/view/edit.xhtml.ftl	(revision 9265)
+++ seam-gen/view/edit.xhtml.ftl	(revision 9402)
@@ -124,7 +124,7 @@
 <#else>
             <h:column>
                 <f:facet name="header">${label(parentProperty.name)} ${label(parentParentPojo.identifierProperty.name)?uncap_first}</f:facet>
-                <@outputValue property=parentParentPojo.indentifierProperty expression="${'#'}{_${parentName}.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}" indent=16/>
+                <@outputValue property=parentParentPojo.identifierProperty expression="${'#'}{_${parentName}.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}" indent=16/>
             </h:column>
 </#if>
 </#if>
