Nested selects

2008-10-11 Thread Francisco Exposito

Hi,

I have to create nested selects for 4 levels. My solution now is one page using 
1 s:doubleselect and once selected the two options, going to the next page 
where I populate another s:doubleselect. 

It is really poor. Is there any way to populate the four select in the same 
page? 

I have some ideas to implement it, but I don't know how implement them and if 
they are possible.

1) Populate only the first select, once the user has selected, ask to the 
database for the second select, and so on. 

2) Populate one doubleselect, after the second selection execute an action (I 
don't know if using javascripts) to populate the other doubleselect...

But I don't know how to implement them. Any help?

Thanks in advance

_
Prueba los prototipos de los Ășltimos en MSN Motor
http://motor.es.msn.com/

Re: Multiple Selects and optionsCollection

2008-03-25 Thread Antonio Petrelli
2008/3/24, Tom Holmes Jr. <[EMAIL PROTECTED]>:
>
> The number of combo-boxes will change dynamically ... based on previous
> information.



I think that, in your case, you need to manage HttpServletRequest parameters
directly. There's nothing wrong with it :-)

Antonio


Multiple Selects and optionsCollection

2008-03-24 Thread Tom Holmes Jr.
I am using struts 1.x and looking at html:select and 
html:optionsCollection for an example on how to use that.

It works great if I have one combo-box with my form.

I have an array of labels:
label_x
label_y
label_z
etc.
each one is a combo-box and they ALL have the same options to pick from, 
and I want capture the data from each of these selects.
The number of combo-boxes will change dynamically ... based on previous 
information.


And I'm trying to build an Action Form to capture all this data 
and then I am trying to use html:select and html:optionsCollection in my 
JSP.


Can anyone point me to good examples on how to construct my formbean and 
jsp page?


In the meanwhile I will keep trying things out. Thanks!

 
Tom




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



LazyValidatorForm not accepting multiple selects

2007-11-04 Thread Donald Rosengartner

I recently joined a team using struts 1.3.8 and LazyValidatorForm. I can not 
seem to get the following html:select to work. I have tried modifying the 
datatype of the form bean property(ArrayList, String[], etc). String[] made the 
first of my selections' values available in the Action, but no other selections 
posted. I have javascript in place to make these selected options "selected", 
so I'm sure the post is not the issue. Switching to the classic ActionForm, all 
values become available with no JSP/javascript changes. My code follows:


 
 Classic Struts accessor - String[] selectedTeams = 
dmaForm.getSchdTrnmtGamesSelected();with LazyValidatorForm -String[] 
selectedTeams = (String[]) dmaUserForm.get("schdTrnmtGamesSelected");// this 
gives ClassCastException, but the next is fine at runtimeString selectedTeams = 
(String) dmaUserForm.get("schdTrnmtGamesSelected");// defeats the purpose, as I 
need all selections that I intended to post
I also tried to access as indexed property of the map, such as String 
selectedTeam1 = (String) dmaUserForm.get("schdTrnmtGamesSelected", 0);String 
selectedTeam2 = (String) dmaUserForm.get("schdTrnmtGamesSelected", 1);The 
zeroeth index returns the same value as that above without the index[0], but 
subsequent values of the index are not populated in the form.
Searching the archives for information on this, I find that String[] is the 
correct datatype, but little if any information about mutiple=true concurrently 
used with LazyValidatorForm.I need to get this working as I have a tiles header 
that requires a lazyValidatorForm in scope. I have a workaround which forwards 
to the init method(as if to read the calling page for the first time), however 
I have other pages that are top-level and are broken until I find a fix.Thanks 
in advance for suggestions givenD. Duane RosengartnerSogeti - Dallas Unit
_
Help yourself to FREE treats served up daily at the Messenger Café. Stop by 
today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline

Re: How do otherS deal with being OO and dealing with multi-selects on front end?

2006-05-11 Thread Adam Hardy
I did (3) slightly differently - I did 
BeanUtils.copyProperties(formBean, Person) in the action, followed by 
the Helper stuff. No great difference really. I think that this is 
really the only feasible current mechanism for it.




Rick Reumann on 11/05/06 19:13, wrote:

What I ended up doing is

1) A Helper class will generate my String[] conversions to and from a
List of "SomeObject"

2) My form beans stick with String[] properties for multiple
selects/multibox situations

3) Rather than use BeanUtils.copyProperties( myFormBean, Person ) in
my Action, I end up putting two methods in my FormBean...

//PersonActionForm
public void PopulatePerson( Person person ) {
   BeanUtils.copyProperties( person, this );
   person.setDogs( Helper.populateDogsFromStringArray( this.dogIds ) );
}

public void PopulateFormFromPerson( Person person ) {
   BeanUtils.copyProperties( this, person );
   this.setDogIds( Helper.populateDogIdsFromDogs( person.getDogs() ) );
}

When inserts or updates are done, all that is needed is typically an
"ID" so what the Helper  class methods do in building the List, of say
Dogs, is just build a Dog object with only the ID populated.

Of course the Person object can now still be used for retrievals when
you really want it to contain complete lists of Dogs and Cats (as an
example).

I'm not super happy with the solution, but it works. In other option
was maybe to just stuff some extra String[] array properties into the
value object but that seems sort of lame.

On 5/11/06, Adam Hardy <[EMAIL PROTECTED]> wrote:

This is something for which I've tried to find an elegant solution on
the last couple of projects I worked on.

Using DTO / POJOs from Hibernate for the Person and the Cats and Dogs, I
end up using a sorted set of Cats or Dogs in the page context, which I
then iterate over in the JSP.

This means the taglib for the checkbox / dropdown control points to the
set / collection and names the methods for the label and the value:



The form therefore has the dogId(s) getter and setter.

However handling the submit where you have to find the Dog pojo with the
chosen ID and place it in the Person.setDog() or Person.getDogs().add()
is frankly complex if not downright ugly (esp if doing deletes!)

There are also issues such as caching of the sets of Cats and Dogs,
limiting the set where business rules apply, and internationalisation.

I intend to develop my caching mechanism soon, and to refactor my ugly
submit helper method to make it handle this juggling of pojos better, so
as you can see I am in the same boat as you.


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



Re: How do otherS deal with being OO and dealing with multi-selects on front end?

2006-05-11 Thread Rick Reumann

What I ended up doing is

1) A Helper class will generate my String[] conversions to and from a
List of "SomeObject"

2) My form beans stick with String[] properties for multiple
selects/multibox situations

3) Rather than use BeanUtils.copyProperties( myFormBean, Person ) in
my Action, I end up putting two methods in my FormBean...

//PersonActionForm
public void PopulatePerson( Person person ) {
   BeanUtils.copyProperties( person, this );
   person.setDogs( Helper.populateDogsFromStringArray( this.dogIds ) );
}

public void PopulateFormFromPerson( Person person ) {
   BeanUtils.copyProperties( this, person );
   this.setDogIds( Helper.populateDogIdsFromDogs( person.getDogs() ) );
}

When inserts or updates are done, all that is needed is typically an
"ID" so what the Helper  class methods do in building the List, of say
Dogs, is just build a Dog object with only the ID populated.

Of course the Person object can now still be used for retrievals when
you really want it to contain complete lists of Dogs and Cats (as an
example).

I'm not super happy with the solution, but it works. In other option
was maybe to just stuff some extra String[] array properties into the
value object but that seems sort of lame.

On 5/11/06, Adam Hardy <[EMAIL PROTECTED]> wrote:

This is something for which I've tried to find an elegant solution on
the last couple of projects I worked on.

Using DTO / POJOs from Hibernate for the Person and the Cats and Dogs, I
end up using a sorted set of Cats or Dogs in the page context, which I
then iterate over in the JSP.

This means the taglib for the checkbox / dropdown control points to the
set / collection and names the methods for the label and the value:



The form therefore has the dogId(s) getter and setter.

However handling the submit where you have to find the Dog pojo with the
chosen ID and place it in the Person.setDog() or Person.getDogs().add()
is frankly complex if not downright ugly (esp if doing deletes!)

There are also issues such as caching of the sets of Cats and Dogs,
limiting the set where business rules apply, and internationalisation.

I intend to develop my caching mechanism soon, and to refactor my ugly
submit helper method to make it handle this juggling of pojos better, so
as you can see I am in the same boat as you.


Regards
Adam


Rick Reumann on 10/05/06 18:12, wrote:
> Lets assume you want to be a good OO developer and you are designing
> an application to handle CRUD stuff for a "Person." Lets say this
> Person can own Cats and Dogs. So person might look like...
>
> Person
> --
> int personId
> String personName
> List dogs; //list of Dog objects
> List cats; //list of Cat objects
>
> Your backend persistence layer of choice knows how to deal with this
> Person. When it goes to insert/update a Person it knows how to update
> the PersonDog and PersonCat tables with respective dog and cat ids.
>
> Where I always run into problems is how to best handle this kind of
> stuff on the front end in Struts for multi select options (and also
> using multibox with checkboxes).
>
> The dilemma first is "What should your PersonActionFrom hold in
> relation to Cats and Dogs when all you need to capture is Dog/Cat Ids
> on you form?"
>
> The standard practice often espoused is your ActionForm should only be
> interested in capturing the inputted data - so in this case it would
> be String[] catIds,  String[] dogIds. This is what I'm currently
> doing, but it then requires an extra conversion to convert these ids
> into "Dog" and "Cat" objects so that I could pass a full "Person"
> object to the backend/service layer.  (You also have to convert going
> back the other way as well for when you want to do an update.)
> Typically I use BeanUtils to do my copying of properties from
> ActionForm --> ValueObject and back the other direction as well.
> Currently I'm having to use special helper covert methods that use a
> combination of BeanUtils and the custom conversions for stuff like
> taking a String[] dogIDs and building Dog objects from them.
>
> Just curious on approaches other people use and how do other
> frameworks, like JSF, deal with this since they don't use ActionForms.
> (For example if I have a "Person" backing bean with "Cats" and "Dogs"
> in it, and my multiselect list allows me to choose dogs and cats, how
> do these get updated in the backing bean.


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





--
Rick

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



Re: Selects

2004-05-14 Thread bOOyah
Jonathan Wright wrote:

Can anyone see anything wrong with the following select and option tags? I
cannot fathom out why I keep getting an exception thrown in the
BodyContent.clearBody method.
This does not work:
  Select One  Auckland  Christchurch   Dunedin  Gisborne   Hamilton  Hastings   Invercargill  Napier   Nelson  New Plymouth  Palmerston North   Rotorua  Tauranga   Wanganui  Wellington   Whangarei  Other
The only way I can get the page to work at runtime with the select tag
included is to do the following:

Even a single white space in the body causes the page to fail, e.g.
 
Any help would be most appreciated!
Hi Jonathan

I copied and pasted your non-working example into my JSP, and added a 
'location' property to my form bean (which I defaulted to "Christchurch" 
in struts-config.xml) and it worked a treat.  No exceptions.

I'm using vanilla Struts 1.1 and JBoss 3.2.3 + Tomcat 4.

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


Selects

2004-05-13 Thread Jonathan Wright
Can anyone see anything wrong with the following select and option tags? I
cannot fathom out why I keep getting an exception thrown in the
BodyContent.clearBody method.

This does not work:
  Select One  Auckland  Christchurch   Dunedin  Gisborne   Hamilton  Hastings   Invercargill  Napier   Nelson  New Plymouth  Palmerston North   Rotorua  Tauranga   Wanganui  Wellington   Whangarei  Other
The only way I can get the page to work at runtime with the select tag
included is to do the following:


Even a single white space in the body causes the page to fail, e.g.
 

Any help would be most appreciated!

Jonathan


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



Problems with Selects

2004-05-13 Thread Jonathan Wright
I've narrowed the javax.servlet.jsp.tagext.BodyContent.clearBody() problem
down to a select tag in my page.

As soon as I put white space or any option tags inside the select's body the
page fails when invoked.

Anyone else encountered similar problems or am I'm omitting something
glaringly obvious??

Jonathan


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