Re: Struts validator Regular Expressions

2004-03-24 Thread Frank Schaare
Hi,

this should be very close to \d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}
I need to validate an IP address and I don't know how is the syntax in the
validator config file.
take your time to study this: 
http://java.sun.com/docs/books/tutorial/extra/regex/
It's worth the trouble, regex rox !

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


Re: Submit Once, Validate Twice -- but how ?

2004-03-24 Thread Frank Schaare
Hi,

thank you, that helps.

Now i still need to know how to access the input page (set in action 
mapping with the input="sample.jsp" tag)...

I don't have sample code but are you looking for something like this:

// in Action execute...
ActionErrors errors = new ActionErrors();
// add errors...
...
// set in request
request.setAttribute("org.apache.struts.action.ERROR", errors);
// forward to same page...
Thanks


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


Submit Once, Validate Twice -- but how ?

2004-03-24 Thread Frank Schaare
Hi,

just read this article on husted.com and it seems to be good advice.

When the user submits a page, passes validation without errors, is there 
a chance to validate business logic in the action ?

Therefor i need to
- make my validation,
- get an errors object,
- store the error,
- put the errors object in the request and
- return to input page.
Has anyone some sample code / suggestions / articles / sources hoe to 
achieve this ?

Thx

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


HowTo logical date validation

2004-03-18 Thread Frank Schaare
Hi all,

i´m looking for some kind of 'logical date validation' which means that 
dates like '2004-02-31' are filtered out and sent back to input page.

Has anyone ever done this before (i´m sure you have ;-)) ?
Are there any sites dealing with this problem ?
thanks for your reply...

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


How to validate selects

2004-03-17 Thread Frank Schaare
Hi all,

i´m doing some selects like this:

  
  

Now, i have to validate, that the user has made his choice, which means 
that the 'foo' property is notNull.

Does anyone have an idea how to realise this in struts ?

Thanks

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


rePost: How to set the selected value in an select rendered by optionsCollection

2004-03-11 Thread Frank Schaare
Hi all,

i´m reposting my problem trying to be a little bit more specific. This 
problem is very important for me, though i made another 'book like' 
example to show where i am.

There are three beans playing in my theatre:
1. the CommonValuesBean which stores frequently asked data for my JSP 
HTMLForms
2. the CustomerBean which is an buisiness objekt representing a customer
3. the DynaForm which stores data coming from my JSP HTMLForms.

First of all, the CommonValuesBean is initialised. Therefore, i´ve got 
the sessionListener that puts data in it, anytime a new session is creatd:

public void sessionCreated(HttpSessionEvent event) {
	CommonValuesBean commonValuesBean = new CommonValuesBean(); // create 
new bean instance
	HashMap countries = new HashMap(); // Create new map
	countries.put("countryCode1","country1")
	countries.put("countryCode2","country2")
	countries.put("countryCode3","country3")
	
	countries.setCountries(countries); // Our example map is now stored
	
	HttpSession session = event.getSession();
	session.setAttribute("commonValuesBean",CommonValuesBean);
}

Now we begin to deal with the customers. There is listCustomers Action 
that shows all of the customers. You can klick one to
get more detailed information using the customersDetailsAction:

public class customersDetailsAction extends Action
{
private Customer customer = new Customer();
	public ActionForward execute(ActionMapping mapping,ActionForm 
form,HttpServletRequest req,HttpServletResponse res)
		throws IOException, ServletException
	{
	customer.setFirstName("Frank");
	customer.setLastName("Schaare");
	customer.setCountry("country2");

	req.setAttribute("customer",customer); // storing customer in request
	
	return mapping.findForward("customerShowDetails"); // mapped to 
customerShowDetails.jsp
	}
}

The customerShowDetails.jsp looks like this:


.
. tons of markup
.

	

.
. again: tons of markup
.



The problem is, that the  renders a select like 
this:


country1
country2
country3

i desperately NEED to render the select like this:


country1
country2   
country3

because my customer lives in country2 !

Is there any way to tell Struts to do this ?

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


Re: How to set the selected value in an select rendered by optionsCollection

2004-03-11 Thread Frank Schaare
Hi Hubert,

This would only be true if the action that was called specified that form in
its mapping.  If this is a preprocessing action (that's being called to
provide an HTML form with data to show), and there's no "name" attribute to
tie a form to it, Struts will not create/populate a form (because it wouldn't
know what form to create).  
Sorry, but i guess you are wrong.

The declared formBeans are digested during ActionServlets.init().

If you have a tool that is able to visualize your Java Objects like the 
'variables' view in Eclipse, you will see the following right after 
applications startup, when setting a breakpoint in any action:

mapping/moduleConfig/formBeans which is a HashMap. All your declared 
beans are right there.

Does anyone know the right way to access this HashMap ?

Anyway, we became very far away from my optionsCollection problem. I´ll 
try to repost it trying to be a little more specific.

CU

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


Re: How to set the selected value in an select rendered by optionsCollection

2004-03-10 Thread Frank Schaare
Hi Wendy,
thx for your reply, but there are some questions left:
this is where i am: there is my business object 'sb' and the upcoming 
DynaActionForm. sb extends ActionForm, there should be sb.execute().

Nope.  It goes request->form creation->action.  You are being passed the form in the signature of ActionForm.execute(), all you have to do is cast it to the right type:

  DynaActionForm dForm = (DynaActionForm) form;
Shall i cast my business object 'sb' ? That would look like this:
DynaActionForm dSB = (DynaActionForm) sb
Or shall i look for the DynaActionForm in sb.execute() which will look 
like this:
sb.execute()
{
//there must be a way to access Struts DynaForms
.
DynaActionForm dSB = (DynaActionForm) form
}
How do i get the form Objekt ?

I debugged deep into Struts sources, found a 'mapping' Object with a 
'formBeans' Vector but no way to access this mapping.
Do you have a suggestion ?



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


How to set the selected value in an select rendered by optionsCollection

2004-03-10 Thread Frank Schaare
 I´ve got this select rendered with data from my applicationwide
formularBean:
 

  

 
 This renders a select like this:

Mrs.
Mr.
Dr.
.
.

 
 The formular fields in my JSP should be prefilled with data from my person
bean ("sb")
 which has a Title property, so sb.getTitle() returns 'Mr.' in this example.
 
 Is there any chance to tell the html:select renderer "hey, if sb.getTitle()
is = 'Mr.' write
  
Mrs.
Mr.
Dr.
.
.
 " ???
 
 I tried this workaround:

  
  


but it rendered:

Mr.
Mrs.
Mr.
Dr.


even if Validator returns to this page because of errors.

Do you have any solutions/suggestions/articels for me to solve this problem
?

-- 
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz


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



optionsCollection with another default value

2003-11-24 Thread Frank Schaare
Hallo,

i´ve made a select from an optionsCollection Tag. The values are read 
from a hashmap like
value1 = one
value2 = two
value3 = three

Now i´d like to set a default value for this select, which is NOT PART 
of my HashMap, f.e "please select..." The rendered select should look 
like this:
please select...
one
two
three

is there any way to achieve this result in struts ?

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


Re: Accessing application scope in Action.execute()

2003-11-10 Thread Frank Schaare
Hi David,

getServlet() followed by two more commands:

getServlet().getServletContext().getAttribute(String);
OR
getServlet().getServletContext().setAttribute(String, obj);
Regards,

this was a great help for me thank you.

Hope my name is shown correctly now...

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