RE: dynamic properties in jsp

2003-09-29 Thread Andrew Hill
Have a look at the nested stuff.
http://www.keyboardmonkey.com/next/index.jsp

-Original Message-
From: hari_s [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 30 September 2003 14:06
To: 'Struts Users Mailing List'
Subject: RE: dynamic properties in jsp


I think it will be simple if u handle it with JavaScript

-Original Message-
From: krishnamohan [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 30, 2003 11:35 AM
To: '[EMAIL PROTECTED]'
Subject: dynamic properties in jsp

Hi,

I am working on a page where the user will dynamically add new rows at
runtime and there is  no limit.   This will be on a button 'Add New
Option'.
So I do not know what properties to create at compile time.  If anybody
has
worked on this type of scenario in struts, pl. help me how to do this or
with some code. I am using struts1.1 and tomcat.

Thanks,
Krishna


-
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]


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



RE: dynamic properties in jsp

2003-09-29 Thread hari_s
I think it will be simple if u handle it with JavaScript

-Original Message-
From: krishnamohan [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 30, 2003 11:35 AM
To: '[EMAIL PROTECTED]'
Subject: dynamic properties in jsp

Hi,

I am working on a page where the user will dynamically add new rows at
runtime and there is  no limit.   This will be on a button 'Add New
Option'.
So I do not know what properties to create at compile time.  If anybody
has
worked on this type of scenario in struts, pl. help me how to do this or
with some code. I am using struts1.1 and tomcat.

Thanks,
Krishna


-
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]



Re: dynamic properties in jsp

2003-09-29 Thread Abhijeet Mahalkar
You have to handale this in JAvascript in which use document.createElement method to 
create the table row,td, and components and values of this u can access in dynaform ...


abhijeet 

- Original Message - 
From: "krishnamohan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 30, 2003 10:05 AM
Subject: dynamic properties in jsp


Hi,

I am working on a page where the user will dynamically add new rows at
runtime and there is  no limit.   This will be on a button 'Add New Option'.
So I do not know what properties to create at compile time.  If anybody has
worked on this type of scenario in struts, pl. help me how to do this or
with some code. I am using struts1.1 and tomcat.

Thanks,
Krishna


-
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]



dynamic properties in jsp

2003-09-29 Thread krishnamohan
Hi,

I am working on a page where the user will dynamically add new rows at
runtime and there is  no limit.   This will be on a button 'Add New Option'.
So I do not know what properties to create at compile time.  If anybody has
worked on this type of scenario in struts, pl. help me how to do this or
with some code. I am using struts1.1 and tomcat.

Thanks,
Krishna


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



dynamic properties

2003-06-19 Thread Jeb Scarbrough
I am still fairly new to java and struts so please forgive me if this
questions doesn't make sense.  I am wanting to dynamically change paths to
files, images, css, etc based on the url used to access the site.  For
example, if a user enters the site via abc.domain.com, I would like the
paths to images to be something along the lines of
/images/abc.domain.com/image.jpg.  I'm sure there are many ways to
accomplish this, but I was trying to find a way to perform this within the
struts framework.  Possibly by dynamically using different property files?
Would this make sense?  Is there be a better solution?  Maybe a filter of
some sort?  Has anyone tried to do something similar?  Any guidance is
greatly appreciated.  Thanks!

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



RE: Real dynamic properties

2003-03-17 Thread WILLIAMS,RAND (HP-USA,ex1)
[ Disclaimer: Others may disagree - I'm new at this ;) ]

The best way is to assign one property to be a HashMap. 
There are limitations - but none that have really stood in
my apps way...


1. See MapBackedForm example in 4.3.2 Map-backed ActionForms
   of
http://jakarta.apache.org/struts/userGuide/building_controller.html#config. 

-  It is possible to refer to elements in the jsp, that do not (yet) have
even corresponding entries in the map... very cool... (see above)

2. On that note, a combination of DynaBean form and mapbackedform would
probably look like


  ...
  
  ...


!! HOWEVER !!
I had significant problems using the above for 


beanUtils refused to populate the field - 
although it would render.

logic:iterate had a problem even when i dealt with each element
as a type="Map.MapEntry".

Craig, maybe it is not putting the Map.Entry back in place on a
populate?? I did have problems using :text and MapEntry - it wouldnt
populate to save it's life...

Anyway, I didn't get what I wanted from DynaBean.
So I've since just 'extended' ValidatorActionForm,
http://jakarta.apache.org/struts/api/org/apache/struts/validator/ValidatorAc
tionForm.html
which seems to work pretty well even with validating fields
of Map (truely dynamic) variables without problem, like this: 

package com.hp.sm.model;

import java.util.Map;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.commons.beanutils.PropertyUtils;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionErrors;

public class SmModelForm 
extends org.apache.struts.validator.ValidatorActionForm {

private static Log log = LogFactory.getLog(SmModelForm.class);
private static boolean debug = true;

private final Map values = new HashMap();
private final Map login = new HashMap();

public void setValue(String key, Object value) {
values.put(key, value);
}

public Object getValue(String key) {
return values.get(key);
}

public ActionErrors validate( ActionMapping mapping,
  HttpServletRequest request) {

// validate using the commons-validator and validation.xml
ActionErrors errors = super.validate(mapping, request);

// perform our additional validation here.
if ( (errors==null) || (errors.isEmpty()) )
  errors = SmModelHelper.validateSmModelForm( this, 
   request.getSession().getServletContext()
);

if ( (errors==null) || (errors.isEmpty()) )
  return null;

return (errors);
}

public void reset() {
  log.info(" reset();");

  values.clear();

  // add some fields I want ...
  setValue("prevState" , new java.lang.String() );
  setValue("state" , new java.lang.String() );
  setValue("valid" , new java.lang.String() );
  setValue("validateModel" , new java.lang.String() );
}

}

[validation.xml]

11 
33
34  
35property="value(password)"
36depends="required" >
37
38  
40  
43
44  
45
57 
59  



-Original Message-
From: Chalkidis Spyros [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 4:26 AM
To: [EMAIL PROTECTED]
Subject: Real dynamic properties



Hello,

is there a way to configure the properties of a DynaActionForm
really dynamically? I mean not to
define them in the struts-config.xml but through java code?

Thanks in advance,

Spyros Halkidis

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



Real dynamic properties

2003-03-17 Thread Chalkidis Spyros

Hello,

is there a way to configure the properties of a DynaActionForm
really dynamically? I mean not to
define them in the struts-config.xml but through java code?

Thanks in advance,

Spyros Halkidis


Re: Dynamic Properties

2002-06-26 Thread Adrian Cunningham

Hi,

I have implemented your code below for dynamic forms and it works a
treat, I might even say it is a little more convenient than the actual
DynaActionForm as you don't have to declare any form properties in the
struts-config file.

Although I do have one question for you.  Have you managed to implement
this using the struts validator?  I would be quite keen on using the
struts validator for dynamic forms/properties with this particular
workaround.  

Regards,
Adrian Cunningham

PS.Out of curiousity what do you think of the workaround I came up
with?



"Bhattad, Nilesh " <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> I'm also facing the same problem of Dynamic properties with Struts 
> 1.0/1.1 As a workaround, I created my own classes DynaForm and 
> DynaFormClass
> 
> I'm attaching a pseudo code of DynaForm and DynaFormClass
> 
> 
> 
> 
> // A Form class which is common for all JSP pages 
>  public class DynaForm extends DynaActionForm
> {
> DynaFormClass formClass = new DynaFormClass();
>   
> public Object get(String name) 
> {
> Object value = dynaValues.get(name);
> return (value);
> }
> 
> public void set(String name, Object value) 
> {
> dynaValues.put(name, value);
> }
> 
> public DynaClass getDynaClass() 
> {
> return (this.formClass);
> }
> }
> 
> 
> 
> 
> // As DynaActionForm needs a descriptor object attached to it, // this

> class implements DynaClass interface and always returns Object // as a

> property. 
> public class DynaFormClass implements DynaClass
> {
>   private static Class cls;
>   private static DynaProperty property;
>   
>   static
>   {
>   cls = new Object().getClass();
>   property = new DynaProperty(null, cls);
>   }
>   
>   public String getName()
>   {
>   return null;
>   }
>   
>   public DynaProperty getDynaProperty(String name)
>   {
>   return new DynaProperty(null, cls);
>   }
>   
>   public DynaProperty[] getDynaProperties()
>   {
>   return null;
>   }
>   
>   public DynaBean newInstance()
>   throws IllegalAccessException, InstantiationException
>   {
>   return new DynaForm();
>   }
> }
> 
> 
> //
> // struts-config.xml
> //
> 
>  type="com.onebeacon.struts.action.DynaForm">
> 
> 
> 
> type="com.onebeacon.struts.action.ActionHandler"
>name="test"
>scope="request">
>
>   
>   
> 
> 
> 
> Please let me know if someone has a better solution for using Dynamic 
> properties.
> 
> Thanks
> Nilesh
> 
> 
> -Original Message-
> From: Daniel Hinz [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 24, 2002 9:44 AM
> To: Struts Users Mailing List
> Subject: Dynamic Properties
> 
> Hi,
> 
> i posted a feature request on struts-dev on friday, which i'd like to 
> bring to this forum for dicsussion. Although this has already been 
> discussed in some threads, a satifactory conclusion has not been 
> reached (at least in my opinion). So here it goes:
> 
> A) Use Cases:
> 1) Develop a generic RDMBS Browser using Struts.
> 2) Develop a WebInterface for arbitrary XML editing.
> 
> B) Problems in Struts 1.0 and 1.1:
> For each property A the corresonding setA / getA methods are invoked 
> upon read/write. There's nothing wrong with that. However i must 
> deploy form fields that are unknown to me at compile-time. Thus i 
> cannot write a Bean with the appropriate methods.
> 
> C) Request for extending org.apache.struts.action.ActionForm:
> A simple solution would be to introduce methods with the following
> signature:
> public void setProperty(String propertyName, Object propertyValue) 
> public Object getProperty(String propertyName)
> 
> D) Workaround:
> None known to me. There's a class called DynaActionForm which allows 
> you to add a dynamic number of fields *in the struts-config.xml file*.

> This is not feasible since the properties are unknown at Servlet 
> Initialization time.
> 
> I'm quite new to Struts so please forgive me if i missed something 
> blatantly obvious.
> 
> Regards,
> 
> Daniel Hinz
> 
> --
> Daniel Hinz
> Software Engineer

Re: Dynamic Properties

2002-06-24 Thread Adrian Cunningham

Hi,

I posted a message last week with a similar problem.  I basically have
several fields on a row in a table, each row containing the same fields
but the number of rows in the table is dynamic and is dependant on a
number of things that aren't defined at compile time.

Although I managed to figure out a workaround based on some other posts
in this group (although not ideal) of sorts and have got the dynamic
form (as described above) to work.

First I have defined a form bean (IterateForm) that contains a Vector
and a constructor capable of initialising it with a fixed number of
blank elements.  Each element is another bean (NameForm) which is
essentially a row in the HTML table containing the dynamic fields.

NameForm.java
-
public final class NameForm extends ActionForm
{
private String title;
private String forename;
private String surname;

public NameForm()
{
title = "";
forename = "";
surname = "";
}

// getters and setters

IterateForm.java
-
public final class IterateForm extends ActionForm
{
private java.util.Vector names;

// Constructor
public IterateForm(int iNumElements)
{
names = new java.util.Vector(iNumElements);

for(int i = 0; i < iNumElements; i++)
{
NameForm nameForm = new NameForm();

nameForm.setTitle("");
nameForm.setForename("");
nameForm.setSurname("");

names.add(nameForm);
}

this.numRows = Integer.toString(iNumElements);
}

public java.util.Vector getNames()
{
return names;
}

// Don't require setter.

My first JSP index.jsp allows you to specify the number of rows for the
dynamic form.

index.jsp
-



Dynamic Forms Using Struts





Dynamic Form Using Struts




Number of Rows: 








This page submits its form to the DynaSetupAction action class.  This
class then creates a IterateForm (above) using the constructor and
passing it the number of rows for the dynamic form, which initialises
the collection with whatever number of elements you want.

DynaSetupAction.java

public final class DynaSetupAction extends Action
{
public ActionForward perform(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest
request,
 HttpServletResponse
response)
 throws IOException,
ServletException
{


int numRows =
Integer.parseInt(((DynaSetupForm)form).getNumRows());

HttpSession session = request.getSession();

// Create IterateForm with dynamic number of rows.
ActionForm iterForm = new IterateForm(numRows);

session.setAttribute("iterateForm", iterForm);
// request.setAttribute("iterateForm", iterForm);

return (mapping.findForward("iterationForm"));
}
}

This action then forwards control back to a JSP named IterateForm.jsp.
Which iterates around the collection creating rows the number of rows
specifid from the index.jsp page.

IterateForm.jsp
---



Dynamic Form Using Struts




Dynamic Form Using Struts



Title
Forename
Surname


 
  
  
  
 













This page then submits its results to the IterateAction action class
which simply forwards control to the results page DynaFormResults.jsp
which displays them. (See Below).

DynaFormResults.jsp
---



Dynamic Form Results Page






Results of Dynamic Form



First Person:







struts-config.xml
--
...
  
  
  
...


...



...


It isn't an ideal way to do it I suppose but it works for what I need.

Adrian Cunningham.



"Daniel Hinz" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> Hi,
> 
> i posted a feature request on struts-dev on friday, which i'd like to 
> bring to this forum for dicsussion. Although this has already been 
> discussed in some threads, a satifactory conclusion has not been 
> reached (at least in my opinion). So here it goes:
> 
> A) Use Cases:
> 1) Develop a generic RDMBS Browser using Struts.
> 2) Develop a WebInterface for arbitrary XML editing.
> 
> B) Problems in Struts 1.0 and 1.1:
> For each property A the corresonding setA / getA methods are invoked 
> upon read/write. There's nothing wrong with that. However i must 
> deploy form fields that are unknown to me at compile-time. Thus i 
> cannot write a Bean with the appropriate methods.
> 
> C) Request for extending org.apache.struts.action.ActionForm:
> A simple solution would be to intr

RE: Dynamic Properties

2002-06-24 Thread Bhattad, Nilesh

I'm also facing the same problem of Dynamic properties with Struts 1.0/1.1
As a workaround, I created my own classes DynaForm and DynaFormClass

I'm attaching a pseudo code of DynaForm and DynaFormClass




// A Form class which is common for all JSP pages

public class DynaForm extends DynaActionForm 
{
DynaFormClass formClass = new DynaFormClass();

public Object get(String name) 
{
Object value = dynaValues.get(name);
return (value);
}

public void set(String name, Object value) 
{
dynaValues.put(name, value);
}

public DynaClass getDynaClass() 
{
return (this.formClass);
}
}




// As DynaActionForm needs a descriptor object attached to it,
// this class implements DynaClass interface and always returns Object 
// as a property.

public class DynaFormClass implements DynaClass
{
private static Class cls;
private static DynaProperty property;

static
{
cls = new Object().getClass();
property = new DynaProperty(null, cls);
}

public String getName()
{
return null;
}

public DynaProperty getDynaProperty(String name)
{
return new DynaProperty(null, cls);
}

public DynaProperty[] getDynaProperties()
{
return null;
}

public DynaBean newInstance()
throws IllegalAccessException, InstantiationException
{
return new DynaForm();
}
}


//
// struts-config.xml
//






   


  


Please let me know if someone has a better solution for using Dynamic
properties.

Thanks
Nilesh


-Original Message-
From: Daniel Hinz [mailto:[EMAIL PROTECTED]] 
Sent: Monday, June 24, 2002 9:44 AM
To: Struts Users Mailing List
Subject: Dynamic Properties

Hi,

i posted a feature request on struts-dev on friday, which i'd like to bring
to this forum for dicsussion. Although this has already been discussed in
some threads, a satifactory conclusion has not been reached (at least in my
opinion). So here it goes:

A) Use Cases:
1) Develop a generic RDMBS Browser using Struts.
2) Develop a WebInterface for arbitrary XML editing.

B) Problems in Struts 1.0 and 1.1:
For each property A the corresonding setA / getA methods are invoked upon
read/write. There's nothing wrong with that. However i must deploy form
fields that are unknown to me at compile-time. Thus i cannot write a Bean
with the appropriate methods.

C) Request for extending org.apache.struts.action.ActionForm:
A simple solution would be to introduce methods with the following
signature:
public void setProperty(String propertyName, Object propertyValue)
public Object getProperty(String propertyName)

D) Workaround:
None known to me. There's a class called DynaActionForm which allows you to
add a dynamic number of fields *in the struts-config.xml file*. This is not
feasible since the properties are unknown at Servlet Initialization time.

I'm quite new to Struts so please forgive me if i missed something blatantly
obvious.

Regards,

Daniel Hinz

--
Daniel Hinz
Software Engineer
[EMAIL PROTECTED]


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

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




Dynamic Properties

2002-06-24 Thread Daniel Hinz

Hi,

i posted a feature request on struts-dev on friday, which i'd like to bring
to this forum for dicsussion. Although this has already been discussed in
some threads, a satifactory conclusion has not been reached (at least in my
opinion). So here it goes:

A) Use Cases:
1) Develop a generic RDMBS Browser using Struts.
2) Develop a WebInterface for arbitrary XML editing.

B) Problems in Struts 1.0 and 1.1:
For each property A the corresonding setA / getA methods are invoked upon
read/write. There's nothing wrong with that. However i must deploy form
fields that are unknown to me at compile-time. Thus i cannot write a Bean
with the appropriate methods.

C) Request for extending org.apache.struts.action.ActionForm:
A simple solution would be to introduce methods with the following
signature:
public void setProperty(String propertyName, Object propertyValue)
public Object getProperty(String propertyName)

D) Workaround:
None known to me. There's a class called DynaActionForm which allows you to
add a dynamic number of fields *in the struts-config.xml file*. This is not
feasible since the properties are unknown at Servlet Initialization time.

I'm quite new to Struts so please forgive me if i missed something blatantly
obvious.

Regards,

Daniel Hinz

--
Daniel Hinz
Software Engineer
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Dynamic Properties and Database

2002-02-18 Thread Bryan Field-Elliot

Take a look at my Simper package, which does basically this:

http://www.netmeme.org/simper

Still rough around the edges, but within a week or so, I hope to make a
polished project out of it (hosted at SourceForge). I've been saying
"within a week or so" for about a month now :( but will really try to
get to it soon. In the meantime it's downloadable and usable in it's
current form. Please read the README first, it explains what the whole
project is about.

Bryan


On Fri, 2002-02-15 at 04:11, Peter Pilgrim wrote:

HI

I have had a look Jan Sorenson's  Dynamic Properties contribution

http://husted.com/struts/resources/DynamicProperties.htm

How useful is this code for reading from and writing to arbitary database
tables. It sounds like I can map any database column name to
an action form property.

For example given the SQL table

create table COFFEE (
 coffee_id integer,
 coffee_namevarchar(null),
 coffee_descvarchar(null),
 . . . )

Mapped to action form accessor and mutator

 public int getCoffee_Id() ;
 public void  setCoffee_Id( int ) ;
 . . .

It looks a bit nasty especially the underscores but I think it could work.

Comments

--
Peter Pilgrim ++44 (0)207-545-9923

 Swamped under electionic mails


--

This e-mail may contain confidential and/or privileged information. If you are not 
the intended recipient (or have received this e-mail in error) please notify the 
sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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






Dynamic Properties and Database

2002-02-15 Thread Peter Pilgrim


HI

I have had a look Jan Sorenson's  Dynamic Properties contribution

http://husted.com/struts/resources/DynamicProperties.htm

How useful is this code for reading from and writing to arbitary database
tables. It sounds like I can map any database column name to
an action form property.

For example given the SQL table

create table COFFEE (
 coffee_id integer,
 coffee_namevarchar(null),
 coffee_descvarchar(null),
 . . . )

Mapped to action form accessor and mutator

 public int getCoffee_Id() ;
 public void  setCoffee_Id( int ) ;
 . . .

It looks a bit nasty especially the underscores but I think it could work.

Comments

--
Peter Pilgrim ++44 (0)207-545-9923

 Swamped under electionic mails


--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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




Re: Dynamic properties in ActionForms with custom tag

2002-01-05 Thread Ted Husted

Mapped properties are supported in the nightly build. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/



Freek Segers wrote:
> 
> Hello again,
> 
> I've partially solved my problem. I found the new commons-beanutils package
> that has new methods in PropertyUtils (getMappedProperty() and
> setmappedProperty()).
> 
> To solve my second problem I now hardcoded my form bean's name into the
> custom tag implementation to look it up in pageContext.
> 
> However, my struts release (version 1.0) doesn't populate the form bean when
> I submit the form. I the servlet log I do see that Struts looks up and
> recycles the form bean and it logs that it populates the form bean but the
> dynamic properties' setter method isn't called.
> 
> Do I need a new struts release that uses the common-beanutils package. If
> so, which build has support for this.
> 
> Thanks again,
> 
> Freek Segers
> 
> on 03-01-2002 08:51 you wrote:
> 
> > First, I've created a custom tag that creates different types of HTML form
> > fields.
> > The number of fields generated varies and the names of the fields are dynamic.
> > I can't figure out how to let Struts populate the ActionForm that's linked to
> > the Action that handles the form.
> > I thought I read somewhere that you can use some feature of the JavaBean specs
> > to tell Struts what method to call (maybe by using PropertyDescriptors?), but
> > I can't find anything about this.
> >
> > Second, I don't know how I can restore any previously submitted values when
> > the form is shown for a second time, for example in case of a validation
> > error. Do I have access to the ActionForm from a custom tag implementation
> > somehow? Or can I let the ActionForm set properties in my custom tag?
> > I've been looking at the source code for the Struts -tag but
> > found no clues to how Struts manages to make the last submitted item selected
> > when the form is redisplayed.
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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




Re: Dynamic properties in ActionForms with custom tag

2002-01-05 Thread Ted Husted

Freek Segers wrote:
> 
> Hello,
> 
> I'm currently working on my first Struts application and I'm facing two problems.
> 
> First, I've created a custom tag that creates different types of HTML form fields.
> The number of fields generated varies and the names of the fields are dynamic.
> I can't figure out how to let Struts populate the ActionForm that's linked to the 
>Action that handles the form.
> I thought I read somewhere that you can use some feature of the JavaBean specs to 
>tell Struts what method to call (maybe by using PropertyDescriptors?), but I can't 
>find anything about this.

The controller uses reflection. If the ActionForm has a property that
matches the name of a parameter, it populates the property with the
parameter's value. 

There are also ways to use hashtables behind ActionForms. See 

http://jguru.com/forums/view.jsp?EID=567079



> Second, I don't know how I can restore any previously submitted values when the form 
>is shown for a second time, for example in case of a validation error. Do I have 
>access to the ActionForm from a custom tag implementation somehow? Or can I let the 
>ActionForm set properties in my custom tag?
> I've been looking at the source code for the Struts -tag but found no 
>clues to how Struts manages to make the last submitted item selected when the form is 
>redisplayed.
> When I use the following Stuts HTML
> 
>  
>  
>  
> 
> how does the select-tag know which ActionForm bean it should use to get the selected 
>item. I've recompiled the select-tag with some debugging output and put it in my own 
>taglib, but the I get the Exception I expected: there is no form bean under the 
>default name used in the select-tag in pageContext.

It looks at the Action specified by the enclosing html:form, and uses
whatever ActionForm is specified by that Action. Alternatively, you can
specify the name of the bean yourself. 


> I'm really at a loss and I hope you can help me with this.
> 
> Thanks in advance,
> 
> Freek Segers

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Dynamic properties in ActionForms with custom tag

2002-01-03 Thread Freek Segers

Hello again,

I've partially solved my problem. I found the new commons-beanutils package
that has new methods in PropertyUtils (getMappedProperty() and
setmappedProperty()).

To solve my second problem I now hardcoded my form bean's name into the
custom tag implementation to look it up in pageContext.

However, my struts release (version 1.0) doesn't populate the form bean when
I submit the form. I the servlet log I do see that Struts looks up and
recycles the form bean and it logs that it populates the form bean but the
dynamic properties' setter method isn't called.

Do I need a new struts release that uses the common-beanutils package. If
so, which build has support for this.

Thanks again,

Freek Segers


on 03-01-2002 08:51 you wrote:

> First, I've created a custom tag that creates different types of HTML form
> fields.
> The number of fields generated varies and the names of the fields are dynamic.
> I can't figure out how to let Struts populate the ActionForm that's linked to
> the Action that handles the form.
> I thought I read somewhere that you can use some feature of the JavaBean specs
> to tell Struts what method to call (maybe by using PropertyDescriptors?), but
> I can't find anything about this.
> 
> Second, I don't know how I can restore any previously submitted values when
> the form is shown for a second time, for example in case of a validation
> error. Do I have access to the ActionForm from a custom tag implementation
> somehow? Or can I let the ActionForm set properties in my custom tag?
> I've been looking at the source code for the Struts -tag but
> found no clues to how Struts manages to make the last submitted item selected
> when the form is redisplayed.


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




Dynamic properties in ActionForms with custom tag

2002-01-02 Thread Freek Segers

Hello,

I'm currently working on my first Struts application and I'm facing two problems.

First, I've created a custom tag that creates different types of HTML form fields.
The number of fields generated varies and the names of the fields are dynamic.
I can't figure out how to let Struts populate the ActionForm that's linked to the 
Action that handles the form.
I thought I read somewhere that you can use some feature of the JavaBean specs to tell 
Struts what method to call (maybe by using PropertyDescriptors?), but I can't find 
anything about this.

Second, I don't know how I can restore any previously submitted values when the form 
is shown for a second time, for example in case of a validation error. Do I have 
access to the ActionForm from a custom tag implementation somehow? Or can I let the 
ActionForm set properties in my custom tag?
I've been looking at the source code for the Struts -tag but found no 
clues to how Struts manages to make the last submitted item selected when the form is 
redisplayed.
When I use the following Stuts HTML

 
 
 

how does the select-tag know which ActionForm bean it should use to get the selected 
item. I've recompiled the select-tag with some debugging output and put it in my own 
taglib, but the I get the Exception I expected: there is no form bean under the 
default name used in the select-tag in pageContext. 

I'm really at a loss and I hope you can help me with this.

Thanks in advance,

Freek Segers




bean with dynamic properties

2001-07-04 Thread suhas



Hi 
    I was not able to understand 
what u mean by bean with dynamic properties ? How this can be done 
?
 
Suhas


RE: Dynamic properties

2001-02-21 Thread Kevin Wang



You 
basically need to add a Hashtable to ActionForm (or its subclass) to hold 
dynamic properties ; PropertyUtils provides set/get methods 
to set/get dynamic properties to the Hashtalbe; and BeanUtils makes usre 
such methods get called before throwing 
a "NoSuchMethodFoundException". I've got it working for simple property with 
12/07/00 nightly built. It should be easy (though time comsuming) 
to do the same for indexed/nested properties.
 
Kevin

  -Original Message-From: Craig R. McClanahan 
  [mailto:[EMAIL PROTECTED]]Sent: Wednesday, February 21, 
  2001 11:33 AMTo: [EMAIL PROTECTED]Subject: 
  Re: Dynamic propertiesAllan Schweitz wrote: 
  

Can anyone tell me if the forms struts 
supports dynamic properties? If so is there an example available on how this 
works?I have a html form that 
builds up dynamically creating a table with checkboxes, text input and 
selectboxes. But since this form is dynamically generated there is no form 
class that reflects the dynamically generated form and struts cannot handle 
it. If anyone knows how to 
solve this in struts please let me know. Thanks in advance, Allan Schweitz[EMAIL PROTECTED]Struts 
  1.0 does not support dynamic properties, but this is on the TODO list for 
  Stuts 1.1.  Given the number of questions about it, I expect it to be 
  fairly high in the priorities. 
  Craig   


Re: Dynamic properties

2001-02-21 Thread Nino Walker



We've modified PropertyUtils.set/getSimpleProperty() to recognize when
the bean is a java.util.Map, and to call .get()/.put() instead of using
introspection.  It's a very minor change, and I can post the source
if anyone is interested.
Nino
"Craig R. McClanahan" wrote:
Allan Schweitz wrote:

Can
anyone tell me if the forms struts supports dynamic properties? If so is
there an example available on how this works?I have a html form that builds
up dynamically creating a table with checkboxes, text input and selectboxes.
But since this form is dynamically generated there is no form class that
reflects the dynamically generated form and struts cannot handle it.
If anyone knows how to solve this in struts
please let me know. Thanks
in advance, Allan Schweitz[EMAIL PROTECTED]
Struts 1.0 does not support dynamic properties, but this is on the TODO
list for Stuts 1.1.  Given the number of questions about it, I expect
it to be fairly high in the priorities.
Craig
 

--
 <-- Nino Walker, Speech Applications Lead, http://www.xtime.com
-->
 




Re: Dynamic properties

2001-02-21 Thread Craig R. McClanahan



Allan Schweitz wrote:

Can
anyone tell me if the forms struts supports dynamic properties? If so is
there an example available on how this works?I
have a html form that builds up dynamically creating a table with checkboxes,
text input and selectboxes. But since this form is dynamically generated
there is no form class that reflects the dynamically generated form and
struts cannot handle it. If
anyone knows how to solve this in struts please let me know. Thanks
in advance, Allan Schweitz[EMAIL PROTECTED]
Struts 1.0 does not support dynamic properties, but this is on the TODO
list for Stuts 1.1.  Given the number of questions about it, I expect
it to be fairly high in the priorities.
Craig
 




Dynamic properties

2001-02-20 Thread Allan Schweitz



Can anyone tell me if the forms struts supports 
dynamic properties? If so is there an example available on how this 
works?
I have a html form that builds up dynamically 
creating a table with checkboxes, text input and selectboxes. But since this 
form is dynamically generated there is no form class that reflects the 
dynamically generated form and struts cannot handle it.
 
If anyone knows how to solve this in struts please 
let me know.
 
Thanks in advance,
 
Allan Schweitz
[EMAIL PROTECTED]


RE: Dynamic properties

2001-01-29 Thread Kevin Wang

check out http://archive.covalent.net/jakarta/struts-user/2000/12/0481.xml
for my previous post on handling dynamic properties with Struts.
unfortunately, it is not working with the latest nightly builds as changes
are significant.

indexed/nested properties were not "dynamically" supported.

> -Original Message-
> From: Matthias Bauer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 29, 2001 3:58 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Dynamic properties
> 
> 
> Hi there,
> 
> this is a very interesting question Bram raised and I would 
> very urgently need
> this feature in my current application, too. So I would 
> really like to know if
> this can be achieved with Struts. Does anybody know, how a 
> form bean could be
> dynamically equipped with properties, so it could be used for 
> multiple forms,
> not just a single one?
> 
> So what I am looking for are the following two things:
> 
> 1. The form bean which is associated to a struts form should 
> be instantiated by
> a factory which decides depending on a cgi parameter which 
> form bean to use.
> 
> 2. The form bean can contain indexed properties which are 
> accessed by methods
> which conform to the JavaBeans specification, e. g. setter(int index,
> PropertyType value).
> 
> If I am getting it right, there is currently no way to 
> accomplish this, because
> Struts only allows static mapping between the form elements' 
> names and the form
> bean elements' names. And you can only define a static 
> mapping from jsp forms to
> form beans in struts-config.xml.
> 
> I would be glad if I were wrong and it is relly an easy thing 
> to do something
> like that. So any suggestions would be very welcome.
> 
> Thanks,
> 
> --- Matthias
> 
> Matthias Bauer +++ [EMAIL PROTECTED] +++ LivingLogic AG +++ 
www.livinglogic.de


> bram wrote:
> 
> Hi,
> 
> Is there any way to dynamicly add properties to a bean?
> 
> The problem is that I have a recordset and want to use the colomn names as
a
> property (indexed) without writing a bean for every possible recordset so
I
> can use it with Struts.
> 
> Bram



Re: Dynamic properties

2001-01-29 Thread Matthias Bauer

Hi there,

this is a very interesting question Bram raised and I would very urgently need
this feature in my current application, too. So I would really like to know if
this can be achieved with Struts. Does anybody know, how a form bean could be
dynamically equipped with properties, so it could be used for multiple forms,
not just a single one?

So what I am looking for are the following two things:

1. The form bean which is associated to a struts form should be instantiated by
a factory which decides depending on a cgi parameter which form bean to use.

2. The form bean can contain indexed properties which are accessed by methods
which conform to the JavaBeans specification, e. g. setter(int index,
PropertyType value).

If I am getting it right, there is currently no way to accomplish this, because
Struts only allows static mapping between the form elements' names and the form
bean elements' names. And you can only define a static mapping from jsp forms to
form beans in struts-config.xml.

I would be glad if I were wrong and it is relly an easy thing to do something
like that. So any suggestions would be very welcome.

Thanks,

--- Matthias

Matthias Bauer +++ [EMAIL PROTECTED] +++ LivingLogic AG +++ www.livinglogic.de


> bram wrote:
> 
> Hi,
> 
> Is there any way to dynamicly add properties to a bean?
> 
> The problem is that I have a recordset and want to use the colomn names as a
> property (indexed) without writing a bean for every possible recordset so I
> can use it with Struts.
> 
> Bram



Dynamic properties

2001-01-27 Thread bram



Hi,
 
Is there any way to dynamicly add properties to a 
bean?
 
The problem is that I have a recordset and want to 
use the colomn names as a property (indexed) without writing a bean for every 
possible recordset so I can use it with Struts.
 
Bram 


How can i implement this? (dynamic properties instead of static ones)1

2001-01-21 Thread Johan Compagner

Hi,

I have a form: PropertyForm
which have a getProperty(String) and a setProperty(String,Object)
So not a get and setter for every property.
That property form relay's those calls to a DbObject that also has those
getProperty and setProperty.
At start (first request of) i set a specifiek DbObject in a PropertyForm
that DbObject get's filled from a database. 
So when i want to add another var, i only have to change the object definition
in the database. Don't have to alter class files (this is not an option must be 
complety configurable)

But now i have a problem with the popupate of the with the TAG's:
they do this:
   match = BeanUtils.getProperty(bean, property);  (RadioTag)
or this:
   Object objvalue = PropertyUtils.getProperty(bean, property); (BaseFieldTag)

(why those 2 different calls to BeanUtils or PropertyUtils?) 

What must i do so that they don't try to find the rigth getter for that 
property but if it is a PropertyForm just call the getProperty(String property) ??

Must i really reimplemt all the TAGS
As far as i can see it would be nice to have a method added to all those tag's 
or just one in the base tag: 

protected String getProperty(Object bean, String property)
{
// Default Implementation
return BeanUtils.getProperty(bean, property); (or PropertyUtils)
}
And all the calls for getting the property call's this method.
Then i can subclass all (or neccessary) Tag's and only reimplemnt that 
getProperty(Object,String) method.

For struts the  behaviour isn't changed. Only you are somewhat flexibler.

Or is there an other approache that i am not seeing at this time?

There are other problems of course when using one Form for more then one Form that my 
site haves.
Because the current implementation will reuse the same form bean when calling a 
specifiek action isn't it?

so if i call:

/nextpage.do?thema=pension
or
/nextpage.do?thema=xxx

Then the same property form will be used?
But i want to use the same Class: PropertyForm.class
but it will get another DbObject (xxx DbObject instead of a pension) 
so it will have different property's

But this behaviour is pretty simple to change just: reimplement one method: 
processActionForm(xx,xxx,xx)

Johan C.