RE: Validator's sucks ??

2003-11-19 Thread Kruse, Matt
 Using either customized Java code or regular expressions, a
 developer can ensure that any incoming form data is legal and valid.
 This is a tremendous help to any developer as it prevents bad 
 data from being processed by their Action and, many times, 
 causing the user to see annoying 500 errors.

I'm not sure why any Action would bomb out from invalid data.
If that happens, IMO, you're putting too much logic in your Action.

IMO, data validation belongs at the BO level. No matter where your data
comes from, your BO should decide for itself whether or not it's valid
before it tries to process it. It shouldn't just assume that it will get
valid data.

For this reason, in one project I completed, we ignored client-side
validation nearly completely, and instead relied on server-side validation
coming from the BO's themselves. This way, no matter what screen tried to do
what operation, correct error messages would be given back to the user and
the screen would re-paint.

This was a lot easier and more logical to me than having each screen (which
is simply a view to data) know exactly what kind of data is valid for what
it is displaying.

Doing it at the BO level, if there is a change in one validation, it gets
changed in one place, no matter how many screens can updated that piece of
data. Much easier, IMO.

So, I'd like the Validator framework to work at the BO level and the
javascript/screen level, and skip the Action level altogether. I prefer my
Actions to be really, really stupid - traffic-controllers only, not data
handlers.

Matt Kruse



Eclipse-like web view framework for struts?

2003-10-27 Thread Kruse, Matt
I would like to build a web app that functions like a control panel with
multiple views of data that the user can close, resize, etc.

What I keep coming back to is wanting something similar to the Eclipse
development environment, where I can pick my views and position them on the
screen and have the layout be customizable by the users. Except in a
browser, probably using frames and/or iframes. Somewhat like a portal, even,
but not exactly.

My target browser will be IE only, so I can do lots of cool things, but I
don't want to get into active X or anything like that. Purely HTML/CSS
browser-based interface.

Is there any kind of framework or UI tool which will get me going with this
kind of approach?

Matt Kruse


RE: question on javascript...

2003-10-19 Thread Kruse, Matt
This is a basic question... Can I find the index of a select box, 
if I have the value or the text ???
document.formName.optionName.options[C].selected=true 
-- This won't work!!
 
You need to loop through each option, checking to see it's value and then
checking it.

var s = document.formname.optionname;
for (var i=0; is.options.length; i++) {
  if (s.options[i].value==C) {
   s.selected=true;
  }
}

Or, using functions at http://www.mattkruse.com/javascript/validations/ you
can do:

setInputValue(document.formname.optionname,C);

Be careful - multiple options are allowed to have the same value!

Matt Kruse


RE: swap values between two select boxes

2003-10-06 Thread Kruse, Matt
I have two select boxes on my jsp page and each of them is 
multiselect set to true.
I am trying to swap values between the two - is it possible ? 

I have a javascript library which will make this easy for you - 
http://www.mattkruse.com/javascript/optiontransfer/

Hope that helps!

Matt Kruse


RE: Know of any good Calendar Tag Libraries? (Sorry, that was Aug 21)

2003-09-25 Thread Kruse, Matt
 I'm aware of Matt's Library (and I love it), but I don't want 
 a pop-up, I want an in-page calendar.

BTW, I'm going to be adding an 'inline' option to the javascript library,
which will then find its way into the taglib also.
Unfortunately, I've not had much time to work on it lately, so the taglib
hasn't been updated yet.
The other options out there seem pretty good, though.

Matt



RE: Is it possible to remove *.do or /do/* from the URL

2003-09-19 Thread Kruse, Matt
 By that argument, GUI apps should not ever disable menu 
 options that are not relevant to the current state of 
 the computation either -- instead, they should just 
 leave the option enabled and deal with it when the user
 selects it.  :-)

I don't think that's a fair comparison, because GUI apps have control over
their interface. Web apps do not have control over their interface. If there
was a standard way to tell all browsers to disable the back button on this
page then I'd say yeah, go for it. But the nature of the web is that you do
_not_ have control over the interface, and your app needs to respond to
whatever the user does, rather than control what they do.

  The fact is that it is HARD to design an app for the 
  web and implement it so that it works well 
  in a browser.
 Not only is it hard, its nearly impossible.

Why do you say this? Can you give examples of situations where a web app
cannot behave in an appropriate way when a user chooses to use the back
button? Every situation I can think of can be handled. In some cases, maybe
the best handling is to simply tell the user you can't submit this page
again, we're now going to take you back to the beginning. to avoid this,
don't use the back button. But that's severe, IMO. Last resort.

 Non-trivial interactive applications (I'm not taking about 
 adding a comment to a guest book; I'm talking about adding 
 an order to a database) have the same kinds of ordering 
 and transactional restrictions, whether you implement them 
 in a client-server GUI in your favorite language, or as a 
 webapp.  It's a different beast.

Even in processing an order, when the user must go down a path one step at a
time, why can't the application handle the back button? What specific cases
are there were using the back button just totally screws everything up in
such a way that the web app could not handle it logically?

Matt



RE: Is it possible to remove *.do or /do/* from the URL

2003-09-18 Thread Kruse, Matt
 The important principle here is Web Application != Web 
 Site.  

Why? In many cases, it's the same difference. These days, web sites
usually are web applications on the back-end. There are a lot of stupid
users out there. In many cases, every attempt needs to be made to cater to
them.

 If your users feel compelled to use bookmarks and the back button in 
 your webapps, despite efforts to train them correctly, this is a pretty 
 good sign that you have not provided enough suitable navigation 
 controls in your basic UI.

On the contrary, I'd say that if your web application can't handle the back
button and bookmarking, then you've designed it incorrectly. ESPECIALLY if
your users want to use them :)

When web applications are done right, they have nice URL's, the back
button can be used without causing any problems, and bookmarking is possible
wherever it makes sense.

IMO, there are too many lazy developers out there who do poor design and
don't consider the 'Back' button, for example, then look for cheap hacks to
stop the user from using it. Instead, they should think differently and
handle these cases. It's sometimes more work, sure, but that's part of the
job!

Matt



RE: can't pass parameters

2003-08-28 Thread Kruse, Matt
The other comments are probably valid, but I thought I would note this:

onclick='document.forms[this.form].param.value=save ;

This should be:

onclick='this.form.param.value=save;'

Matt Kruse



RE: Validator JavaScript and html:radio buttons

2003-08-26 Thread Kruse, Matt
 IIRC, it's invalid HTML unless exactly one of the radio 
 button options is selected.  

That's not true. Not really. From the specs:

QUOTE
Radio buttons are like checkboxes except that when several share the same
control name, they are mutually exclusive: when one is switched on, all
others with the same name are switched off. The INPUT element is used to
create a radio button control. 
If no radio button in a set sharing the same control name is initially on,
user agent behavior for choosing which control is initially on is
undefined. Note. Since existing implementations handle this case
differently, the current specification differs from RFC 1866 ([RFC1866]
section 8.1.2.4), which states: 

At all times, exactly one of the radio buttons in a set is checked. If none
of the INPUT elements of a set of radio buttons specifies `CHECKED', then
the user agent must check the first radio button of the set initially.

Since user agent behavior differs, authors should ensure that in each set of
radio buttons that one is initially on.
/QUOTE

Authors _should_ pre-check one item, but are not required to.

Since it's not possible in most UI's to set a radio group back to no items
selected it's usually bad design to have none selected initially. The user
can't restore the form to its original state if they accidently click in the
wrong place.

I would be able to tell you why the JS is failing if you post the source,
but a better solution might be to re-think your design and consider whether
a group of radio buttons is really the interface you want to use.

Matt Kruse


Calendar Popup taglib

2003-08-21 Thread Kruse, Matt
I now have a (very beta) version of the calendar popup taglib available for
download and testing:
http://www.mattkruse.com/javascript/javascripttoolbox.zip

I'm not sure if it's in a correct or usable form as-is, but anyone familiar
with Struts should be able to get the examples running in their container of
choice.

I have a few more things to add (like setting disabled dates, etc) but I
wanted to get some feedback now before cleaning everything up and adding
more functionality.

If you have any thoughts, please let me know so I can make it more useable
to the struts community!

Matt Kruse


RE: is there any Dependable Option List Tag ?

2003-08-20 Thread Kruse, Matt
If we have two related Drop Down boxes in a Form and need 
 to populate those when we load the page and when we change 
 the value in the first drop down we need to load the 
 corresponding values in the second .. Can any
 TagLib supports this..

I don't have it in the form of a taglib (yet) but I do have javascript to
handle this:
http://www.mattkruse.com/javascript/dynamicoptionlist/

You can just loop through your array list of values or whatever and print
out the require javascript lines. Some day I'll have a tag lib created to
make the whole process less painful...

Matt



Can an INPUT tag know its form name? Also, application resources...

2003-08-20 Thread Kruse, Matt
In writing a taglib for my calendar popup, I've come across two questions:

1) I need to write javascript which references the generated input tag. To
do this, I need to know the name of the form that it is contained in to get
a javascript reference to it. If no form name is found, I'll default to form
[0]. This isn't working:

protected String getFormName() {
// Acquire the form tag we are associated with
FormTag formTag =
(FormTag)pageContext.getAttribute(Constants.FORM_KEY);
if (formTag==null) {
return 0;
}
else {
return '+formTag.getName()+';
}
}   

I took this from the html:option tag as an example. Is this not possible
for the form tag?

2) I have a .properties file for my taglib which defines standard text and
default options. It would be great if a user could over-ride those settings
with messages in their own application-specific MessageResources. Is there a
generalized way, in my taglib code, to get a reference to the application's
message resources so I can search for keys that over-ride my defaults?
The other option I thought of is that the developer can extend my taglib
with their own and point to their own MessageResources file, but this isn't
as slick. 
Any other options?

PS: Just have to clear up these two things and write more examples and it'll
be ready for testing...

Thanks!

Matt Kruse


Suggestions for Calendar Popup taglib?

2003-08-18 Thread Kruse, Matt
I'm going to have some free time soon and I plan to convert my calendar
popup javascript (http://www.mattkruse.com/javascript/calendarpopup) into a
tag lib to be easily used in struts apps.

If anyone has suggestions on how it should work or features it should
support, please let me know!

Also, should it be extending the struts html:input tag, or since those will
one day go away, should I be extending a different taglib? I'm more familiar
with the struts tags (extended them before) but I want the tag to be useable
by the majority of struts developers :)

Matt


RE: Suggestions for Calendar Popup taglib?

2003-08-18 Thread Kruse, Matt
 When we implemented out calendar one of the things we needed 
 to do was make holiday dates unchoosable. So I'm not allowd 
 to make a booking on 25th Dec etc. It might be worth thinking 
 of some way in which you can pass in a collection of dates 
 that are highlighted differently/disabled.

That's already supported in the javascript library, so there will be
corresponding tag arguments to pass these into the java side of things.
Perhaps something that will take an ArrayList of Date objects to be
disabled? Then the styles of the calendar will take care of how to display
these dates which are not selectable.

Matt



RE: Suggestions for Calendar Popup taglib?

2003-08-18 Thread Kruse, Matt
 Does this mean it'll write JS for the popup calendar too?

Yes, definitely. I might include the full JS source as a tag too, so you
could just do

mk:calendar-src/

at the top of your page and all the required library source would be written
out. Or you could manually link to the libraries. Not sure what the standard
way to do this is when a tag requires javascript libs.

 I like the div version - which requires a
 hidden div and such - so I hope you'll incorporate this.

Yup, will do. A newer (unreleased) version of the calendar popup
automatically generates a DIV object and inserts it into the page source,
so you don't even need to have an empty div sitting there. But for now, I'll
just write out the DIV tag from the doStartTag() method so the user
doesn't need to worry about anything at all.

 I always use a image icon for my calendar links - so I'd like to
 see that as an option.  

Indeed, I have linkText and linkImage as properties, so you can use either
one. Or neither, if you want it to popup onFocus of the form field. Options,
options, options...

Matt



RE: Suggestions for Calendar Popup taglib?

2003-08-18 Thread Kruse, Matt
In working on this, I've come up with a couple of things that would be very
handy to have:

1) A simple dummy struts app which would be ready for me to plugin my
taglib to test. I know that creating a little app won't take long, but a
nice little starting point would be convenient.

2) Any type of documentation for the standard way to release taglibs. What
directory structure and contents are expected? Is there a standard way to do
it?

Either of those would be helpful to me, if anyone can point me somewhere.
Thanks!

Matt


 -Original Message-
 From: Kruse, Matt [mailto:[EMAIL PROTECTED]
 Sent: Monday, August 18, 2003 9:56 AM
 To: Struts Users Mailing List (E-mail)
 Subject: Suggestions for Calendar Popup taglib?
 Importance: High
 
 
 I'm going to have some free time soon and I plan to convert 
 my calendar
 popup javascript 
 (http://www.mattkruse.com/javascript/calendarpopup) into a
 tag lib to be easily used in struts apps.
 
 If anyone has suggestions on how it should work or features it should
 support, please let me know!
 
 Also, should it be extending the struts html:input tag, or 
 since those will
 one day go away, should I be extending a different taglib? 
 I'm more familiar
 with the struts tags (extended them before) but I want the 
 tag to be useable
 by the majority of struts developers :)
 
 Matt
 


RE: Dependent select boxes

2003-07-22 Thread Kruse, Matt
 I have an application that uses dependent select boxes, 
 ie, by picking one item in a select box, then the contents 
 of the next one will be decided.

I have a javascript library which does exactly this.
Check it out: http://www.mattkruse.com/javascript/dynamicslelectbox/

Matt


RE: Cascade Select

2003-07-03 Thread Kruse, Matt
 (4.) Use JavaScript. Something along the lines of
   html:select property=yerFormProperty 
 onchange=document.yourForm.otherSelectBox.value=this.value /
 This seems really obvious to me, though, so maybe I'm missing 
 something.

You can do the javascript approach easily using a library such as:
http://www.mattkruse.com/javascript/dynamicoptionlist/

There are no struts tags to go along with it right now, but eventually, if I
ever get the time, I'll be adding jar and tld files to make this integrate
nicely with struts.

Matt Kruse



RE: Submiting a form through a link

2003-06-29 Thread Kruse, Matt
a href= onclick=document.forms[0].submit();return false;Click
here/a
The above code works for me. Not sure if the return false; has 
any impact - probably does nothing.

The return false is definitely important. It tells the browser that, after
running the commands in the onClick handler, it should NOT go to the href.
If you return true (default) then the browser will go to the href after
running the commands.

In this case, if you aren't returning false, then the form will submit and
the browser will immediately abandon that request and instead try to go to
the href URL, making it look like nothing happened.

Matt


RE: Indexed properties and JavaScript

2003-06-25 Thread Kruse, Matt
 I hadn't tryied this, and it has worked on IE 6 and
 Opera 7.1, but not on Netscape 7 !

Try this instead:

document.forms['testForm']['att[0]'].value

That should work in any browser.

Matt Kruse


RE: Problems removing (expiring Cookie) in Action

2003-06-25 Thread Kruse, Matt
 Is there anything that I need ot be aware of in terms of
 expiring/removing a Cookie within an Action?  I'm setting the maximum
 age to 0 and then adding the cookie back to the response and somehow
 that cookie shows up after I've forwarded my request to the 
 next action.
 I'm I missing a step?  

The cookie will continue to exist in your request until the server sends the
response back without the cookie, and the browser makes another request not
including the cookie.

If you are forwarding from one Action to another without redirect, you get
the same request as the first action, and the cookies are still there.

Unless I'mm understanding your situation incorrectly

Matt Kruse



RE: Escaping ' and in bean:write output for javascript?

2003-06-24 Thread Kruse, Matt
 From: Gemes Tibor [mailto:[EMAIL PROTECTED]
 addName('bean:write name=person property=lastname 
 filter=true/');
 This filters the html sensitive chars. 

Nope, that doesn't do the job (filter is true by default, btw).

It creates output like this:

addName('O#39;Reilly');

which causes javascript errors.
Instead, it should be:

addName('O\'Reilly');

Since I already had my own taglib which wrapped bean:write, I just added
another attribute called javascriptEscape to be set to either true or false.

It does:
  ' to \'
   to quot;
  \n(newline) to \n (\\n)
  \r(newline) to \r (\\r)

Matt


RE: Escaping ' and in bean:write output for javascript?

2003-06-24 Thread Kruse, Matt
 Which is exactly what the string taglib does from
 jakarta.apache.org, plus a lot of other cool things (think wordwrap
 and nl2br)

I will check this out later. I just didn't want to introduce another taglib
into this project at this point in the game. Too many unknown variables!

I'm still not sold on the value of taglibs, but it's good to know that there
are people out there solving the problems before I get to them :)

Matt



Escaping ' and in bean:write output for javascript?

2003-06-23 Thread Kruse, Matt
Simple question,

When I want to use bean:write to print a value into a JSP, to be included
as an argument in a javascript function, how can I escape the output in
cases where it has ' and  and newline characters?

For example,
  addName('bean:write name=person property=lastname/');

If the lastname is O'Reilly, this causes a javascript error because the
output looks like:
  addName('O'Reilly');
When it SHOULD look like:
  addName('O\'Reilly');

I don't see anything in the docs to handle this - do I need to extend
bean:write with my own taglib?

Matt Kruse


RE: Why is dbcp / pool removed?

2003-06-10 Thread Kruse, Matt
 The one included is not the same as what is in RC1, though, 
 correct? 
 I'm not sure what Ted changed but you may be correct that 
 it's not exactly 
 the same.  You can still use DBCP, Struts just won't 
 distribute it any more.

If I move away from DBCP and try to use just the features included with RC2
(for now), it seems like there have been a lot of changes.

GenericDataSource now handles all the pooling and stuff itself, instead of
relying on BasicDataSource, which is fine.
But, it also relies on GenericConnection, of which there are two versions -
one for JDK1.3, one for JDK1.4. And the one for JDK1.3 will _not_ compile
JDK1.4. (according to the docs). That's a bummer, because if I release an
app with the 1.3 version packaged in, and the server is upgraded to 1.4, I'm
going to assume that things will break?

I'm not looking for a long-term fix, just a short-term switch to possibly
avoid the problems that DBCP might have been causing for me. I'm just
finding it a challenge to figure out which short-term fix to use.

 You're not tying your app to the container because you configure the 
 DataSource implementation entirely in JNDI (my preference) or 
 struts-config.xml.

In struts-config.xml, if I define my type= to be a container-specific class,
though, then it's no longer portable. Unless I'm completely misunderstanding
what you mean, which is likely :)

I'm going to explore better ways to handle db connections in the future,
but as I said above, I'm just looking for a patch to address current
problems with DBCP, so I want to keep defining my db conns in
struts-config.xml, and I want to rely only on the classes packaged with
struts (if possible). I'll experiment and see how it works!

Matt Kruse



RE: Why is dbcp / pool removed?

2003-06-10 Thread Kruse, Matt
 The Struts distribution no longer includes DBCP but it does 
 still work with
 it. You can continue to use DBCP in your app as you did 
 before. 

I know :)  But, I was having some problems already that I suspect are due to
that way DBCP is (or isn't!) working, so I did want to replace it with the
new approach in RC2, until I explore JNDI further.

So, I don't want to use DBCP anymore, but I want to continue using
struts-config to define my db so as not to disrupt the current state of the
app too much. So I'm learning how the DBCP-independent RC2 handles the db
connections all internally, and trying to figure out if that will work and
what problems might exist with it. Having some luck so far, but I need to do
a lot more playing around to make sure this doesn't replace my old problems
with new ones :)

Matt


Debugging Connection Pooling Problems? (dbcp, sybase)

2003-06-09 Thread Kruse, Matt
Can anyone recommend a smart way to debug connection pooling issues? 

I'm using BasicDataSource, connecting to a Sybase11 server. It seems that
every night, all idle connections are closed by the server (no app
activity), but for some reason that's not detected by the connection pool.
Our app hangs while trying to get a connection, and I can't figure out why.
It doesn't even come back after the maxWait time and give me an exception
- it just waits forever.

I've logged the active and idle connection counts, and they are sitting at
like 1-3 each, so it's not approaching the limits of 20 active and 4 idle.

Here is my config inside of struts-config.xml:

data-source key=TEST type=org.apache.commons.dbcp.BasicDataSource
 set-property property=defaultAutoCommit value=true/
 set-property property=description value=TEST/
 set-property property=driverClassName
value=com.sybase.jdbc.SybDriver/
 set-property property=maxActive value=20/
 set-property property=maxWait value=1/
 set-property property=maxIdle value=4/
 set-property property=minCount value=2/
 set-property property=validationQuery value=SELECT 1/
 set-property property=password value=pass/
 set-property property=url value=jdbc:sybase:myserver:9996/
 set-property property=username value=user/
/data-source

I've seen mention of the following items and I'm trying to learn more:

 - autoReconnect : Apparently set in the URL. Is this db-specific or
jdbc-specific?

 - removeAbandoned : Not quite sure what this does or if it would help,
given that I have a validationQuery?

 - testOnBorrow : Should this test the conn every time I get one? Isn't that
the point of the validationQuery?

Any ideas would be greatly appreciated. I'm trying to see under the hood
of the connection pooling, but not much is exposed for me to look at.

Matt Kruse


RE: Why is dbcp / pool removed?

2003-06-09 Thread Kruse, Matt
Struts 1.1 includes its trusty old GenericDataSource but you 
can always plugin DBCP if you want.

Hold on a second...

Isn't GenericDataSource deprecated? I just recently switched from using
GenericDataSource in my struts-config.xml (by specifying no type=) to
explicitly using type=org.apache.commons.dbcp.BasicDataSource because of the
docs in GenericDataSource. Is this no longer the recommended approach?

Currently, I'm having some problems with pooling and idle connections which
are closed by the db server actually being given back to my app (I suspect).
Could this be related to the bugs in dbcp you are talking about?

Using 1.1RC2, what is the recommended way to acquire pooled db connections?

Matt Kruse


RE: Why is dbcp / pool removed?

2003-06-09 Thread Kruse, Matt
Isn't GenericDataSource deprecated?
Yes, it will be removed in 1.2 but is included in 
1.1 for backward compatibility.

The one included is not the same as what is in RC1, though, correct? I'm
just trying to figure out exactly what is changed and what I need to start
experimenting with...

 I recommend using the package distributed with either your 
 container or your database.

If you tie your app to your coontainer, then it's not very portable, no? I
can develop in Tomcat and publish to JRun with no problems, and I like to
maintain that :)

I suppose for now a good plan would be to use GenericDataSource and research
more reliable and portable options for conn pooling in the future? Perhaps
by then DBCP will be cleaned up and a good stand-alone alternative.

Matt Kruse


RE: calling actions directly

2003-06-06 Thread Kruse, Matt
 I read that one of the things about struts is the actions are 
 only able to be called from the pages directly. Ie, you 
 shouldn't be able to bookmark the actions themselves like:
 http://myhost/myaction.do

Where did you hear this? That's totally not true - any action can be called
directly as long as it has a mapping. It's just a URL. Otherwise, how would
you enter the first action? :)

Perhaps what you're thinking of is that JSP files should not be called
directly or bookmarked. They should be hidden from the user completely, and
only accessible through an action.

Matt Kruse



Log file viewer servlet for log4j?

2003-06-05 Thread Kruse, Matt
Is there a good pre-packaged log-file viewing servlet available anywhere?

Preferrably something that could take my log4j.properties file as the only
parameter and allow me to view all the different files I've defined, their
backup files, etc, and page through or filter the contents. Even if it's a
quick-and-dirty little utility, it might be useful to me. Any thoughts?

Matt Kruse


RE: Possible Bug in FieldChecks.validateRequiredIf(...)

2003-06-04 Thread Kruse, Matt
 Am I correct in assuming that the following condition 
 ((value != null)  (value.length()  0)) should be
 (!GenericValidator.isBlankOrNull(value)).  The reason my check is
 failing is due to the fact the value I'm checking is all 
 white space (at certain times), and is selected from 
 a select box.

I disagree with your assumption that   should fail a required check.
In some situations, that may be a valid value to be submitted. It exists,
and it has a value. A validation check for the field being required should
pass.

It sounds like what you want is a not blank validation, where a value
consisting of all whitespaces, tabs, or newlines would fail.

I think the two are not the same, but that's just my opinion :)

Matt Kruse


RE: switch between selects

2003-06-03 Thread Kruse, Matt
 I'd like to allow a user to select items using a kind of 
 switch lists.
 Do you know how to perform this using Struts ?
 Or maybe another method ?

Unless you want to go back to the server with each click of 'add' and
'delete' etc (not recommended) you'll need to use JavaScript.
I have a library which allows you to do exactly what you're asking for:
http://www.mattkruse.com/javascript/optiontransfer/

Hope that helps,

Matt Kruse



RE: html:option dependant on prior html:option

2003-05-30 Thread Kruse, Matt
   Is there a way to make a pull down menu using the 
 Struts html:option tag 
 dependant upon another pull down menu on the same page?

Unless you want to go back to the server every time they change the first
drop-down list (not recommended) then you'll need to use Javascript. I have
a library to do exactly this:
http://www.mattkruse.com/javascript/dynamicoptionlist/

This is #2 on my list of javascript libs I want to convert into struts tags,
so hopefully in the near future creating dependent lists will be much
simpler :)

Matt Kruse



RE: How to change label on a html:file button

2003-05-29 Thread Kruse, Matt
 I would like to change the label: 'browse' on the button to 
 some other text.

Unfortunately, you can't. This is a limitation of HTML, not Struts.
There are some really, really funks tricks with DHTML and hidden form
fields, etc, which can simulate this, but trust me, you don't want to use
them.

The file input element is under the control of the OS, and you can't even
have much control over the style and appearance of the browse button.

Matt Kruse



RE: javascript nested:iterate property reference

2003-05-29 Thread Kruse, Matt
 I have to believe someone out there has done something 
 similar and is as 
 little expert in mixing javascript and struts as I am.

As soon as I get extra time, I _will_ be putting this calendar into a struts
taglib, so no one will need to fight this anymore :)

I'll point out a couple of issues and hope that they will help you along:

 document.forms[0].elements['targetDate'].value = m + - + d + - + y;
 input type=text name=eventList[0].targetDate value=05-31-2003

'targetDate' is not the name of your field. 'eventList[0].targetDate' is.

Technically, this is an invalid name for an input field, but we'll ignore
that fact because it's now become more common with PHP and Struts and who
knows what else creating this type of field name.

To reference an invalid form field name like this, you will need to use a
reference like this:

document.forms[0]['eventList[0].targetDate']

But, since you're using the 'select' method, you don't even need to define
the setReturnFunction or anything. Just use select() and pass it the form
field to populate and format.

So, I think what you really want is:

a HREF=# 
 
onClick=cal1.select(document.forms[0]['eventList[0].targetDate'],'anchor1',
'MM/dd/'); return false;
   NAME=anchor1 ID=anchor1

Try that and see if it works :)

Matt Kruse


RE: Calendar tag lib

2003-03-19 Thread Kruse, Matt
 http://www.mattkruse.com/javascript/
 has a nifty calendar popup for a client side date picker.

Now that I am getting into using Struts, I plan to wrap my javascript
calendar popup inside a taglib to make integration easier. Watch the above
URL in the next few weeks and it'll hopefully show up.

Matt Kruse



RE: Calendar tag lib

2003-03-19 Thread Kruse, Matt
 Will it be i18N compliant?

In what sense? The javascript itself is already able to be customized by
changing day/month names, week start day, date format, etc. These will then
become parameters in the taglib. Or do you mean that it should automatically
do these things based on which locale is being used? I have to admit, I
don't know anything about how Struts/taglibs handle that, so I will need to
look into that as well. But my goal is to have it be as automated as
possible with logical defaults, in addition to having everything
customizable.

If anyone has further thoughts, feel free to take this off-list and contact
me directly!

Matt