Re: How to format the actionerrors and actionmessages in the jsp page?

2007-07-29 Thread M.Liang Liu
Hi, Richard Sayre
Thanks for ur reply.
I have been looking for a solution by myself but to find that there was none
to resolve it just change the configuration-file.
I have no experience in taking use of FreeMarker.

However,ur way may be just the only one.

I will just try and thanks for ur comment.

Good luck!

M.Liang
On 7/29/07, Richard Sayre <[EMAIL PROTECTED]> wrote:
>
> For clarification the following line:
>
>
> <#include "/${parameters.templateDir}/xhtml/validationarea.ftl" />
>
> was added to the first line of form.ftl
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
  --M.Liang Liu


Re: How to format the actionerrors and actionmessages in the jsp page?

2007-07-29 Thread Richard Sayre
For clarification the following line:


<#include "/${parameters.templateDir}/xhtml/validationarea.ftl" />

was added to the first line of form.ftl

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to format the actionerrors and actionmessages in the jsp page?

2007-07-29 Thread Richard Sayre
Hi,

I had the same problem.  I did not like the way the error were being
displayed (In a new row above the field that has the error)  To do
this I have to chenge the XHTML template

First I removed the validation from the controlheader-core

<#--
REMOVED
We have our own Error area

<#if hasFieldErrors>
<#list fieldErrors[parameters.name] as error>

<#if parameters.labelposition?default("") == 'top'>
<#rt/>
<#else>
<#rt/>

${error?html}<#t/>
<#lt/>



-->

I added this to the form.ftl

<#include "/${parameters.templateDir}/xhtml/validationarea.ftl" />

In that file I wrote the following code:  It output all of the error
into a single div.  'Holder Div' is used so the client side
validations will work too.


<#assign hasErrors = fieldErrors?exists/>

<#if hasErrors>
<#if (fieldErrors?size > 0) >

<#assign keys = fieldErrors?keys>
<#list keys as key>

<#list fieldErrors[key] as errorMessage>

${errorMessage?html} 












Next I had to change the validation.js file to use my div to display the errors:

function addError(e, errorText) {
try {


var errorDiv;
var error = document.createTextNode(errorText);
var br = document.createElement("br");

//Create the errorDiv it it does not already exist
if(!document.getElementById("errorDiv")) {

errorDiv = document.createElement("div");
errorDiv.setAttribute("id", "errorDiv");
errorDiv.setAttribute("class", "errorMessage");
errorDiv.setAttribute("className", "errorMessage"); //ie
hack cause ie does not support setAttribute


} else {
errorDiv = document.getElementById("errorDiv");
}

errorDiv.appendChild(error);
errorDiv.appendChild(br);

//Make sure all error moessage are display before showing the div
if(!document.getElementById("errorDiv")) {
 document.getElementById("holderDiv").appendChild(errorDiv);
}


} catch (e) {
alert(e);
}
}

function clearErrorMessages(form) {

var errorDiv;
var errorDivChildren;
 if(document.getElementById("errorDiv")) {

   errorDiv = document.getElementById("errorDiv");

   document.getElementById("holderDiv").removeChild(errorDiv);


 }


}

I commented out all of the logic in clearErrorLabels() since it does
not apply to what I am doing.

I think thats about everything. There might be one or 2 places you
have to change some code in the template.   The big thing here is you
have to change the XHTML template.  I'm not sure if the simple
template has error handling, it might be easier to change.

Rich

On 7/27/07, M.Liang Liu <[EMAIL PROTECTED]> wrote:
> Hi,all:
> I would like to add header and footer to the actionerrors so as to it can
> display in the way my client like.
> In Struts1.2,i can just put the following code in the properties file:
> 
> errors.header=
> errors.prefix=
> errors.suffix=
> errors.footer=
> 
> and it could work as I excepted.
> Now i am trying to use struts2,but it can NOT work in the same way.
>
> Any help?
>
>
> btw,I have put the code in the globalMessages.properties and put the file in
> the classpath,as well as defined the struts.xml as:
> 
>
> Thanks for reading and looking forward to any reply.
>
> --
>   --M.Liang Liu
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to format the actionerrors and actionmessages in the jsp page?

2007-07-28 Thread Nuwan Chandrasoma

Hi,

I think you have to change the actionerror.ftl and actionmessage.ftl 
file  to customize the error/message display. i am not sure there may be 
some other way to do this also.


Thanks,

Nuwan

Bhuwan wrote:
Hey! I am having the same issue. 
Have you found out a solution for it by any chance?


Your help is greatly appreciated.

Bhuwan.


M.Liang Liu wrote:
  

Hi,all:
I would like to add header and footer to the actionerrors so as to it can
display in the way my client like.
In Struts1.2,i can just put the following code in the properties file:

errors.header=
errors.prefix=
errors.suffix=
errors.footer=

and it could work as I excepted.
Now i am trying to use struts2,but it can NOT work in the same way.

Any help?


btw,I have put the code in the globalMessages.properties and put the file
in
the classpath,as well as defined the struts.xml as:


Thanks for reading and looking forward to any reply.

--
  --M.Liang Liu





  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to format the actionerrors and actionmessages in the jsp page?

2007-07-28 Thread Bhuwan

Hey! I am having the same issue. 
Have you found out a solution for it by any chance?

Your help is greatly appreciated.

Bhuwan.


M.Liang Liu wrote:
> 
> Hi,all:
> I would like to add header and footer to the actionerrors so as to it can
> display in the way my client like.
> In Struts1.2,i can just put the following code in the properties file:
> 
> errors.header=
> errors.prefix=
> errors.suffix=
> errors.footer=
> 
> and it could work as I excepted.
> Now i am trying to use struts2,but it can NOT work in the same way.
> 
> Any help?
> 
> 
> btw,I have put the code in the globalMessages.properties and put the file
> in
> the classpath,as well as defined the struts.xml as:
> 
> 
> Thanks for reading and looking forward to any reply.
> 
> -- 
>   --M.Liang Liu
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-format-the-actionerrors-and-actionmessages-in-the-jsp-page--tf4157146.html#a11848528
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to format the actionerrors and actionmessages in the jsp page?

2007-07-27 Thread M.Liang Liu
Hi,all:
I would like to add header and footer to the actionerrors so as to it can
display in the way my client like.
In Struts1.2,i can just put the following code in the properties file:

errors.header=
errors.prefix=
errors.suffix=
errors.footer=

and it could work as I excepted.
Now i am trying to use struts2,but it can NOT work in the same way.

Any help?


btw,I have put the code in the globalMessages.properties and put the file in
the classpath,as well as defined the struts.xml as:


Thanks for reading and looking forward to any reply.

-- 
  --M.Liang Liu