Converting data in a ActionForm

2004-01-22 Thread Peter Sloots
Hi

I'm using the following code in a ActionForm to convert 3 strings to a Timestamp,
problem is that some of the string are null, getBirthdateMonth() is still null because 
setBirthdateMonth()
is called after setBirthdate(). Can someone tell me what is the right approach.

I would like to handle all the dataconversion in the form class.
Now I'm calling setBirthdate() from the Action class, to make this work.
But I don't see a way to get the values from the form before the setBirthdateMonth is 
called.

What is a best practice to do this kind of dataconversion.


public String getBirthdate() {
Date birthdate = null;
Timestamp ts = this.data.getBirthdate();
if (ts != null) {
birthdate = new Date(ts.getTime());
setBirthdateDay(formatDay.format(birthdate));
setBirthdateMonth(formatMonth.format(birthdate));
setBirthdateYear(formatYear.format(birthdate));
return ts.toString();
}
return null;
}

public void setBirthdate(String birthdate) {
Date date = formatBack.parse(getBirthdateYear() + "-" + 
getBirthdateMonth() + "-" + getBirthdateDay(), new java.text.ParsePosition(0));
Timestamp ts = null;
if (date != null) {
ts = new Timestamp(date.getTime());
this.data.setBirthdate(ts);
}
}





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



RE: [other] error tag PS

2003-12-22 Thread Peter Sloots
Hi

with you can read messages from your properties file

btw, If I get nothing back in JSP it's because I forget the taglibs...
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
*** REPLY SEPARATOR  ***

On 22-12-2003 at 5:37 Jerald Powel wrote:

>it just occurrred to me, perhaps it may be due to the JSP:
>
>
>
>as ActionMessages are not soley used for error handling? If this is the
>case, what error tag will extract the error labels defined in my
>Application.properties?
>
>thanks again
>
>
>
>G
>
>
>-
>  Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download 
> Messenger Now




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



Re: Access ResourceBundle

2003-12-19 Thread Peter Sloots
Here you go?

<%
  org.apache.struts.util.MessageResources mr = 
org.apache.struts.validator.Resources.getMessageResources(request);
  if (loginForm.getUsername.equalsIgnoreCase( mr.getMessage("key.value") )
  {

  }
%>


*** REPLY SEPARATOR  ***

On 19-12-2003 at 13:34 Manuel Lenz wrote:

>Hi to all,
>it is simple to get Data from the strutsRessourceBundle with the jspTag.
>But I need to get ResourceData inside a java-Part of the jsp-page and
>inside an ActionClass.
>
>For example
>
><%
>  if (loginForm.getUsername.equalsIgnoreCase( ResourceData )
>  {
>
>  }%>
>
>Does anybody know how to get the Data?
>
>Cheers,
>Manuel
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




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



Global-exceptions

2003-12-19 Thread Peter Sloots
Hi all

I'm a bad coder so sometimes I get nullpointer exceptions thrown back from an action
So I declared a global-exception in my struts-config.


  


Problem is that I'm losing the message that comes with the exception.
Is there a way to get the complete message?

In an action when I use new ActionError("error.database", exception.toString()
the complete error is shown by using 

I tried <%= request.getAttribute(org.apache.struts.Globals.EXCEPTION_KEY) %>
but this only gives me java.lang.NullPointerException

TIA Peter








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



Getting Messages in an Action from multiple bundles

2003-11-14 Thread Peter Sloots
Hi

I have multiple resources




In jsp I can get the values by doing




But how do I get the values from resources with the config key in an action?
Somewhere I read it's possible by doing:
MessageResources mr = (MessageResources)request.getAttribute("config");
But this is not working for me.

I tried a work around by using
org.apache.struts.taglib.bean.MessageTag mt = new 
org.apache.struts.taglib.bean.MessageTag();
mt.setBundle("config");
mt.setKey("anotherValue");
but how do I read the variable
mt.getValue("anotherValue"); gives me null

ne1?




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