Re: newbie working with forms

2001-05-21 Thread Tom Janofsky


Try something like:







see http://developer.irt.org/script/form.htm#7.2 for more goodies

--tom

jeff olshesky wrote:
> 
> does anybody know of a way to call multiple action
> classes from one form?  i would like to have to submit
> buttons on the form, both submitting the form to
> unique action classes.  does this require the use of
> the javascript event handlers?  not too familar with
> this, any help would be greatly appreciated.
> 
> thanks,
> jeff
> 
> =
> What would you do if you weren't afraid?
> 
> __
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/



Re: Auto Form/Action Class Code Generator?

2001-05-21 Thread Tom Janofsky


If not, I'd be happy to work with someone on one.  This would fit well
with how we generally do screens anyay.

Let me know.

--tom

"du Clos, John" wrote:
> 
> Before we contemplate doing this, I wanted to ask the list if this has
> already been done.
> 
> Is there a code generator (nothing fancy) that can read an existing .html or
> .jsp file and generate the corresponding Form and Action classes.  The
> generator would identify the variables from the presentation forms
> (html/jsp) and automatically generate corresponding skeleton classes for
> Form and Action.
> 
> The benefits of this is that it allows your graphical designers to design
> the forms first, then the code generator can give the developers a jump
> start by creating the skeleton classes; thus developers can jump start
> coding actual business logic.
> 
> Thanks,
> JD



Re: must restart tomcat

2001-02-14 Thread Tom Janofsky



Just FYI - it's not that hard.

toolkits to get this info
 http://www.inf.fu-berlin.de/~dahm/JavaClass/ (lgpl'd byte code tools)
or
 CFParse from IBM alphaworks 
 (both can be used the get all the classes used by a class)

some tools that do this sort of thing...
 http://vorlon.eecs.cwru.edu/~jrl7/java/ImportMin.txt (tells you what
you need to import)
 Dash-o also does something like this to clean up imports, and
woodenchair's Utility+

Although I'd bet my $.02 that all tomcat 4.x does is watch timestamps on
all the files under classes.

And slightly OT - wasn't life nice and simple in Java before you had to
understand class loaders...?

--tom

"Shkuro, Yuri" wrote:
> 
> I am not aware of any mechanisms in Java to inspect a class and determine
> its dependencies (although javac obviously has to do it, but its
> proprietory).
> I think this issue is too difficult for any container to handle
> automatically.
> 
> -Original Message-
> From: gustav spellauge [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 14, 2001 3:21 PM
> To: [EMAIL PROTECTED]
> Subject: Re: must restart tomcat
> 
> thanks,
> 
> that's what i thught but now i can be quit shure.
> 
> do you think/know if tmcat 4.x will support hotswapping of all dependencies
> ?
> 
> g.
> 
> "Shkuro, Yuri" wrote:
> 
> > Tomcat 3.2 only supports hot-swapping of servlet classes, but not their
> > dependencies like bean classes, so you either have to restart Tomcat, or
> > use its admin interface to remove your application context and add it
> again.
> >
> > Note that the latter is not necessarily faster (usually takes me four hits
> > on the URL: list/delete/add/list), unless you have many applications in
> your
> > webapp directory (and you shouldn't if you plan to restart often).  Also,
> > I noticed that when a context is added via admin interface, Tomcat does
> > not set init parameters for this context, which my application depends on.
> >
> > YS.
> >
> > -Original Message-
> > From: Maya Muchnik [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 14, 2001 2:47 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: must restart tomcat
> >
> > I think, you need to config your server.xml file to tell to "reload" your
> > classes after they are changed / rebuilt.
> > Do you config server.xml for your new application?
> >
> > gustav spellauge wrote:
> >
> > > again my qustion:
> > >
> > > after a change in any of a formbean class or an action class i will have
> > > to restart tomcat (3.2) otherwise my app. runs into cast-exceptions.
> > >
> > > is there any way to avoid this restart. maybe something is wrong with my
> > > setup.
> > >
> > > thanks in advance
> > >
> > > g.



Getting a value in the JSP from an ActionForm

2001-02-06 Thread Tom Janofsky


Here's my dilemma (see 2 summary questions at end):

I'm coming to a page with a value set in an ActionForm by my action for
me.  Works great.  Now what I want to do is get that property out of
that bean, and into another bean that's only being used on the page. 
Something conceptually like:




No go.  Any thoughts on an easy way to do this?

Alternatively I thought html:form looked up the bean, and put it under
the name that i have registered in struts-config.xml for form-bean.  So
after my html:form tag, I tried:


<%
  page_only_bean.setXXX(bean_name_from_form-bean_tag.getXXX());
%>

Again, no dice.  JSP compiler says no such variable.


Anyway, I guess this boils down to 2 simple questions:

1) (The most importnant) I've got an ActionForm that is populated and
passed all around.  I can directly manipulate it in Action classes no
problem.  html:text and bean:writes work fine.  Now how do I get a real
reference to the ActionForm in the JSP?  (Why?  What if I want to call
getXXX() or setXXX() on the Form bean in a scriptlet?)

2) Is there a way using bean:define to copy a property from one bean
into another bean?  (Don't think so, although I can make a bean that
consists just of that property...)


Thanks,

--tom



Re: Tomcat/Struts-friendly hosting services

2001-02-06 Thread Tom Janofsky


I signed up with www.aoindustries.com for web hosting becasue of their
good java support.  Tomcat 3.2.1 is on the list, but I haven't tried
it.  Great customer service though IMHO.

--tom

Tom Miller wrote:
> 
> Any recommendations on web hosting services that support Tomcat 3.2.1?
> I'm especially interested in experiences in fielding a Struts based site
> with a reasonably priced hosting service that was/is a good bet to
> recommend to clients. Has anyone compiled a list somewhere?
> 
> TIA
> 
> --
> Tom Miller
> [EMAIL PROTECTED]
> 641.469.3535 Phone
> 413.581.6326 FAX



Re: using

2001-02-02 Thread Tom Janofsky


You can use javascript for this:





And as per the suggestion Peter made to me the other day, use the same
sort of call to modify the form action before posting if you're posting
to different locations.

--tom

Justin Kennedy wrote:
> 
> Hi all
> 
> I've created a form like so:
>  type="com.admin.forms.UsersForm">
> 
> which contains a select box named 'username'
> 
> I want to provide a link which will post the form. I've created
> UsersForm.java to validate, and it returns an error if username isn't
> selected. Everything works fine with:
> 
> 
> But I want to accomplish this with:
> Add User
> 
> When I click on this link, it comes back to the same page with the error
> message I provided in UsersForm.validate() of "you must select a username",
> even though I've selected a username.
> 
> So, by specifying users.do for page in  servlet populate UsersForm with the request params and call validate ? It's
> obviously calling validate, but the bean properties seem like there not
> being set.
> 
> The reason I want links instead of submit button is because I'm going to
> have multiple links that specify a different '?action=' so the target page
> can process accordingly
> 
> Thanx,
> -Justin



Re: ActionError without using message resource?

2001-02-01 Thread Tom Janofsky


Good question.  Is the use of ActionError and the properties file
coupled?  Or can you code your errors in-line?

--tom

> Mike Bell wrote:
> 
> Hello,
> 
> Is it possible to create an ActionError without using a message
> resource?
> At this time we don't really have a need for a message resource and
> would
> like to just put the error message string directly in the call.
> 
> like:
> 
> ActionErrors errors = new ActionErrors();
> errors.add("name", new ActionError("The Error String"));
> 
> -Mike
>



Re: Dynamic form action?

2001-01-29 Thread Tom Janofsky


Then do I take it that you don't use the  tag?  Or is there a
way to make it happy with no action?  I tried setting the action to be
non-existent (no action attribute), or null (action = "null"), but both
blow up on load because the corresponding mapping isn't found in the
 in struts-config.xml.  Or do you just put a dummy
entry in there?

--tom

Peter Alfors wrote:
> 
> We chose to use one Action class per user action as well.  To do this, we
> use javascript to switch the form action.  Our buttons call a generic
> javascript function (that we have as a javascript import file) that simply
> sets the form action.  The method requires the form, and action to call as
> parameters.
> This allows up to use one JSP page for viewing, editing, and adding it we
> would like.
> 
> JavaScript:
> 
> function performAction(theForm, theAction) {
>   theForm.action = theAction;
>   theForm.submit(theForm);
> }
> 
> Page button:
> 
> onClick="performAction(document.myForm, 'MyAction.do')
> 
> As a default, we do not set an action in the form tag on any of our pages.
> Each button is responsible for setting the action that it would like to
> initiate.
> 
> HTH,
> Pete
> 
> Tom Janofsky wrote:
> 
> > Hi:
> >
> > I'm relatively new to Struts and I'm trying to figure out if there's an
> > easy way to do the following.
> >
> > I'm trying to solve a classic Add/Edit/Delete problem, and I want to
> > know if there is a way to dynamically change the action that the form is
> > posting to, based on an attribute of the bean.  I want to do this
> > because I want to be able to have the following architecture:
> >
> > [1 JSP view]
> >|-addAction -> (forwards to view)
> >|-editAction -> (forwards to view)
> >|-deleteAction -> (forwards to view)
> >
> > All of which use the same form bean, and all forward back to the same
> > view, which has a different button and differnt target (action) if
> > adding or editing.
> >
> > I've written one jsp that does the add, a form bean that has all the
> > fields, and 3 actions that add, edit and delete.  Add is easy, it's the
> > action of the form, delete is easy, it keys off links in the jsp, but
> > I'd like to use the same jsp for the edit screen, but change the url the
> > form is posting to (to the edit action) and also change the buttons.
> >
> > In servlet world, this was:
> >
> > if (action.equlas("add")){
> > out.println("");
> > else {//edit
> > out.println(" > }
> >
> > and similarly for the buttons.
> >
> > I've been through the example app looking for this might have worked,
> > but it doesn't really seem to work that way (i.e., EditSubscription
> > looks at the hidden field does create or edit, and Save does save, or
> > delete, also based on the action field.)
> >
> > I'd rather not embed checking the action in the the "Action" class (this
> > being the bane of heavy controller servlets past, but I want to go with
> > one "Action" per user action.  One alternative (based off an example dug
> > out of the archives) seems to be another "Controller"
> > action, which looks at the action field in the bean, and picks, and
> > destination based off that, but I don't like that, because that seems
> > like the very type of problem Struts is trying to solve.
> >
> > Or would a Struts guru care to make a case for what I want to do not
> > being a best practice?
> >
> > --tom janofsky



Dynamic form action?

2001-01-29 Thread Tom Janofsky


Hi:

I'm relatively new to Struts and I'm trying to figure out if there's an
easy way to do the following.  

I'm trying to solve a classic Add/Edit/Delete problem, and I want to
know if there is a way to dynamically change the action that the form is
posting to, based on an attribute of the bean.  I want to do this
because I want to be able to have the following architecture:

[1 JSP view]
   |-addAction -> (forwards to view)
   |-editAction -> (forwards to view)
   |-deleteAction -> (forwards to view)

All of which use the same form bean, and all forward back to the same
view, which has a different button and differnt target (action) if
adding or editing.

I've written one jsp that does the add, a form bean that has all the
fields, and 3 actions that add, edit and delete.  Add is easy, it's the
action of the form, delete is easy, it keys off links in the jsp, but
I'd like to use the same jsp for the edit screen, but change the url the
form is posting to (to the edit action) and also change the buttons.

In servlet world, this was:

if (action.equlas("add")){
out.println("");
else {//edit
out.println("