Different ways of using seam s:decorate and s:validate – Sample are based on Seamgen based applications.

May 19, 2009 by nmrmohanraj
  1. <s:decorate> without template attribute and with <s:validateAll>, requiredMessage, validateLength samples.

    <s:decorate>

    <s:validateAll>

    <div class=”prop”>

    <s:label id=”editLabel” styleClass=”#{invalid?’errors’:”}”>

      created by

      <s:span styleClass=”required” rendered=”true”>*</s:span>

      </s:label>

    <span id=”editSpan” class=”#{invalid?’errors’:”}”>

      invalid value > #{invalid}

    <ice:inputText id=”createdById” requiredMessage=”This field value is required.” partialSubmit=”true” size=”100″ maxlength=”130″ value=”#{userHome.instance.createdBy}”>

      <f:validateLength maximum=”5″ minimum=”1″ />

      </ice:inputText>

      </span>

      <s:message styleClass=”error errors” />

      </div>

      </s:validateAll>

      </s:decorate>

 

Note: The reason being used s:decorate is that #{invalid} and #{required} are available inside s:decorate; #{required} evaluates to true if you have set the input component being decorated as required, and #{invalid} evaluates to true if a validation error occurs.

 

 

  1. <s:decorate> without template attribute and <s:validateAll>, validateLength and with only required=”true” also work!!!.

 

<s:decorate>

<div class=”prop”>

<s:label id=”editLabel” styleClass=”#{invalid?’errors’:”}”>

  created by

  <s:span styleClass=”required” rendered=”true”>*</s:span>

  </s:label>

<span id=”editSpan” class=”#{invalid?’errors’:”}”>

  invalid value > #{invalid}

<ice:inputText id=”createdById” requiredMessage=”This field value is required.” partialSubmit=”true” required=”true” size=”100″ maxlength=”130″ value=”#{featureSetHome.instance.createdBy}”>

  </ice:inputText>

  </span>

  <s:message styleClass=”error errors” />

  </div>

  </s:decorate>

 

 

  1. With just <s:decorate>, required=”true”, s:message and without requiredMessage attribute.

    <s:decorate>

    <div class=”prop”>

    <s:label id=”editLabel” styleClass=”#{invalid?’errors’:”}”>

      created by

      <s:span styleClass=”required” rendered=”true”>*</s:span>

      </s:label>

    <span id=”editSpan” class=”#{invalid?’errors’:”}”>

      invalid value > #{invalid}

    <ice:inputText id=”createdById” partialSubmit=”true” required=”true” size=”100″ maxlength=”130″ value=”#{featureSetHome.instance.createdBy}”>

      </ice:inputText>

      </span>

      <s:message styleClass=”error errors” />

      </div>

      </s:decorate>

Difference between setOrder and setOrderColumn in Seam

May 5, 2009 by nmrmohanraj

Difference between setOrder and setOrderColumn in Seam

 

  1. This code work fine.

programList.setOrder(“program.programName asc, program.programId desc”);

 

  1. The below code snippet won’t work –
    1. programList.setOrderColumn(“program.programName asc, program.programId desc“);
    2. programList.setOrderColumn(“program.programName asc);

       

      It throws the following exceptions – Caused by java.lang.IllegalArgumentException with message: “invalid order column (“program.programName asc, program.programId desc” must match the regular expression “^\w+(\.\w+)*$”)”

       

    3. This works fine – programList.setOrderColumn(“program.programName”);
      1. But we have to set

        customerList.setOrderDirection(“asc”); or customerList.setOrderDirection(“desc”);

     

     

 

Internationalize Apache Web server or Apache HTTP server error message

December 5, 2008 by nmrmohanraj

Introduction

Some customers want to internationalization and customize error messages to display in end-user browser, whenever some error occurred in the server side. Ex: Tomcat server is down; some server resources are not available etc.

This document talks about customize error message and internationalize error messages–

The version I used is –

1.    Apache2.2

Please follow the following step to configure successfully

1)   Customize error message

a.     Open “httpd.conf” from “C:\Program Files\Apache Software Foundation\Apache2.2\conf”and search for “ErrorDocument” word in the doc.

b.    You can find something like –

# Customizable error responses come in three flavors:

# 1) plain text 2) local redirects 3) external redirects

#

# Some examples:

#ErrorDocument 500 “The server made a boo boo.”

#ErrorDocument 404 /missing.html

#ErrorDocument 404 “/cgi-bin/missing_handler.pl”

c.     Just uncomment whatever error code message you would like to display.

Ex:

ErrorDocument 404 /missing.html

 

d.    Syntax:ErrorDocument error-code document

e.    Create the file (missing.html) in the following path “C:\Program Files\Apache Software Foundation\Apache2.2\htdocs

f.      Whenever you have got 404 error code – missing.html would display.

2)   Internationalize error messages

a.     Open “httpd.conf” from “C:\Program Files\Apache Software Foundation\Apache2.2\conf”and search for “ErrorDocument” word in the doc.

b.    You can find something like-

 # Customizable error responses come in three flavors:

c.     And above  to this line add the following code in “httpd.conf” –

Alias /error/ “C:/Program Files/Apache Software Foundation/Apache2.2/error/”

<Directory “C:/Program Files/Apache Software Foundation/Apache2.2/error”>

            AllowOverride None

            Options IncludesNoExec

            AddOutputFilter Includes html

            AddHandler type-map var

            Order allow,deny

            Allow from all

            LanguagePriority en cs de es fr it nl sv pt-br ro

            ForceLanguagePriority Prefer Fallback

</Directory>

ErrorDocument 503  /error/HTTP_SERVICE_UNAVAILABLE.html.var

 

d.    So finally, it would appear like this –

Alias /error/ “C:/Program Files/Apache Software Foundation/Apache2.2/error/”

<Directory “C:/Program Files/Apache Software Foundation/Apache2.2/error”>

            AllowOverride None

            Options IncludesNoExec

            AddOutputFilter Includes html

            AddHandler type-map var

            Order allow,deny

            Allow from all

            LanguagePriority en cs de es fr it nl sv pt-br ro

            ForceLanguagePriority Prefer Fallback

</Directory>

 

#

# Customizable error responses come in three flavors:

# 1) plain text 2) local redirects 3) external redirects

#

# Some examples:

#ErrorDocument 500 “The server made a boo boo.”

#ErrorDocument 404 /missing.html

ErrorDocument 503  /error/HTTP_SERVICE_UNAVAILABLE.html.var

#ErrorDocument 503 /missing.html

#ErrorDocument 404 “/cgi-bin/missing_handler.pl”

e.    If you to customize the error message displayed from “HTTP_SERVICE_UNAVAILABLE.html.var

                                          i.    You can open the “HTTP_SERVICE_UNAVAILABLE.html.var” file in some text editor

                                         ii.    And change the message under appropriate language  type-

Ex:  “Content-language: en”

3)    internationalized error documents ref

a.     http://www.devshed.com/c/a/Apache/Custom-Error-Pages-with-Apache/2/

b.    http://www.linuxforums.org/forum/servers/42579-help-apache-error-message.html

c.     http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467004

d.    http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_23365486.html

Configuration / Integrating Tomcat and Apache Web server or Apache HTTP server on Windows

December 4, 2008 by nmrmohanraj

The version I used is –

1.    Java version “1.5.0_15″

2.    Apache2.2

3.    Apache-tomcat-6.0.16

4.    Tomcat-connectors-1.2.27-src.zip

5.    Apache Tomcat Connectors 1.2.27 for WIN32

Please follow the following step to configure successfully

1)   Installing Apache –

a.     Download “apache_2.2.10-win32-x86-openssl-0.9.8i.msi”

b.    Just simple wizard – follow next button

c.     Type http://localhost/ in browser

                                          i.    You will get “it works!”

                                         ii.    Ref :

2)   Installing Tomcat

a.     Download “apache-tomcat-6.0.16.zip”

b.    Just unzip it

c.     Goto TOMCAT_HOME/bin and run or double click startup.bat

                                          i.    For ex : C:\apache-tomcat-6.0.16\bin

d.    Type http://localhost:8080/ in browser

                                          i.    You will get

                                         ii.    Ref:

3)   Stop both servers now

a.     Stopping apache

                                          i.    Right click apache service icon

                                         ii.    And click “Open Apache Monitor

                                        iii.    Click Stop button.

b.    Stopping tomcat

                                          i.    Press “Ctrl^C” in the tomcat console

4)   Download “Tomcat-connectors-1.2.27-src.zip” and unzip it.

a.     Copy the following files from “C:\tomcat-connectors-1.2.27-src\conf

                                          i.    uriworkermap.properties

                                         ii.    workers.properties

                                        iii.    workers.properties.minimal

b.    Paste in here – “C:\apache-tomcat-6.0.16\conf”

5)   Download “mod_jk-1.2.27-httpd-2.2.10.so” from the following path

a.     Path : http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.27/

b.    Ref:

c.     Rename from “mod_jk-1.2.27-httpd-2.2.10.so” to “mod_jk.so

d.    Copy “mod_jk.so” and paste in here – “C:\Program Files\Apache Software Foundation\Apache2.2\modules”

6)   Configure Apache

a.     Open “httpd.conf” from “C:\Program Files\Apache Software Foundation\Apache2.2\conf”

b.    Add the following code snippet at the end of the file “httpd.conf”

LoadModule jk_module “C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so”

 

JkWorkersFile “C:/apache-tomcat-6.0.16/conf/workers.properties”

JkLogFile “C:/apache-tomcat-6.0.16/conf/from_apache_mod_jk.log”

JkLogLevel info

JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“

 

# Send servlet for context /examples to worker named ajp13

JkMount /examples ajp13

# Send JSPs for context /examples/* to worker named ajp13

JkMount /examples/* ajp13

7)   Configure Tomcat

a.     Open “server.xml” from “C:\apache-tomcat-6.0.16\conf\server.xml”

b.    Add the following inside “<Server>” element

  <Listener className=”org.apache.jk.config.ApacheConfig” modJk=”C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so” />

c.     Add the following between “<Host>”  “</Host>”

<Listener className=”org.apache.jk.config.ApacheConfig” modJk=”C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so” />

8)    Start tomcat

9)   Wait sometime 5 or 10 seconds

10)                 Start apache

a.     Start apache

                                          i.    Right click apache service icon

                                         ii.    And click “Open Apache Monitor

                                        iii.    Click Start button.

11) Type “http://localhost/examples/

a.     Ref:

b.    Click “Servlets examples

 

 

                                    

Hello world!

December 4, 2008 by nmrmohanraj

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!