Help dynamic selects

View: New views
4 Messages — Rating Filter:   Alert me  

Help dynamic selects

by Juancevi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, my name is John I am from Argentina, I am newbie at trails, I have nested combos mark the link
http://www.nabble.com/Enum-in-search-tt18317768.html#a18319874
but I can not be that I'm doing wrong.


Region---

  @OneToMany(mappedBy = "region", cascade = CascadeType.ALL)
  @JoinColumn(name = "region_id")
  @Collection(child = false , allowRemove=false)
  public List<Pais> getPaises() {
    return paises;
  }


Pais---

  @OneToMany(mappedBy = "pais", cascade = CascadeType.ALL)
  @JoinColumn(name = "pais_id")
  @Collection(child = true)
  public List<Provincia> getProvincias() {
    return provincias;
  }


Provincia---

  @ManyToOne
  @Transient
  @InitialValue("pais.region")
  public Region getRegion() {
    return region;
  }


  @ManyToOne
  @PossibleValues("region.paises")
  public Pais getPais() {
    return pais;
  }


I want when choosing a region, only to drain the countries of that region, but this I do not works.

Any help thank you very much!

Re: Help dynamic selects

by Alejandro Scandroli-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Juan

There is some inconsistencies in your mappings.
But I tried to fix them to send you a working example and I found out
that I can't make the PossibleValues annotation work outside the
Simple example. So maybe there is something wrong or some
configuration missing. I will try again tonight, and let you know.

Saludos.
Alejandro.

PD:- I'm from Argentina too :)


On Sun, Jul 5, 2009 at 7:20 PM, Juancevi<juancesarvillalba@...> wrote:

>
> Hello, my name is John I am from Argentina, I am newbie at trails, I have
> nested combos mark the link
> http://www.nabble.com/Enum-in-search-tt18317768.html#a18319874
> but I can not be that I'm doing wrong.
>
>
> Region---
>
>  @OneToMany(mappedBy = "region", cascade = CascadeType.ALL)
>  @JoinColumn(name = "region_id")
>  @Collection(child = false , allowRemove=false)
>  public List<Pais> getPaises() {
>    return paises;
>  }
>
>
> Pais---
>
>  @OneToMany(mappedBy = "pais", cascade = CascadeType.ALL)
>  @JoinColumn(name = "pais_id")
>  @Collection(child = true)
>  public List<Provincia> getProvincias() {
>    return provincias;
>  }
>
>
> Provincia---
>
>  @ManyToOne
>  @Transient
>  @InitialValue("pais.region")
>  public Region getRegion() {
>    return region;
>  }
>
>
>  @ManyToOne
>  @PossibleValues("region.paises")
>  public Pais getPais() {
>    return pais;
>  }
>
>
> I want when choosing a region, only to drain the countries of that region,
> but this I do not works.
>
> Any help thank you very much!
> --
> View this message in context: http://www.nabble.com/Help-dynamic-selects-tp24345072p24345072.html
> Sent from the Trails - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Help dynamic selects

by Alejandro Scandroli-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Juan!

I found the culprit.
There is a missing key in the editorMap in the archetype's
applicationContext.xml
Here it is:

                                <entry>
                                        <key>
                                                <value>
supportsExtension('org.trails.descriptor.annotation.PossibleValuesDescriptorExtension')
                                                        or
supportsExtension('org.trails.descriptor.annotation.InitialValueDescriptorExtension')
                                                </value>
                                        </key>
                                        <bean class="org.apache.tapestry.util.ComponentAddress">
                                                <constructor-arg index="0">
                                                        <value>trails:Editors</value>
                                                </constructor-arg>
                                                <constructor-arg index="1">
                                                        <value>filteredAssociation</value>
                                                </constructor-arg>
                                        </bean>
                                </entry>

You need that entry in place to make  @PosibleValues work.

About the mapping thing:

*  @ManyToOne and  @Transient are incompatibles
*  "mappedBy"  properties are readonly, you will need some extra code
to make them "editable"
*  It's best to use the Collection's inverse property together with the mappedBy
* If Provincia is a "child" collection (aka: composition) region &
pais properties should be readonly,  there is no point in using the
@PosibleValues there. If you want to use @PosibleValues Provincia
shouldn't be marked as "child" collection.

I'm sending you two mapping examples one with Provincia as a
composition and the other one with Provincia as an aggregation.

I hope it helps.
Saludos.
Alejandro.

On Mon, Jul 6, 2009 at 1:07 PM, Alejandro
Scandroli<ascandroli@...> wrote:

> Hi Juan
>
> There is some inconsistencies in your mappings.
> But I tried to fix them to send you a working example and I found out
> that I can't make the PossibleValues annotation work outside the
> Simple example. So maybe there is something wrong or some
> configuration missing. I will try again tonight, and let you know.
>
> Saludos.
> Alejandro.
>
> PD:- I'm from Argentina too :)
>
>
> On Sun, Jul 5, 2009 at 7:20 PM, Juancevi<juancesarvillalba@...> wrote:
>>
>> Hello, my name is John I am from Argentina, I am newbie at trails, I have
>> nested combos mark the link
>> http://www.nabble.com/Enum-in-search-tt18317768.html#a18319874
>> but I can not be that I'm doing wrong.
>>
>>
>> Region---
>>
>>  @OneToMany(mappedBy = "region", cascade = CascadeType.ALL)
>>  @JoinColumn(name = "region_id")
>>  @Collection(child = false , allowRemove=false)
>>  public List<Pais> getPaises() {
>>    return paises;
>>  }
>>
>>
>> Pais---
>>
>>  @OneToMany(mappedBy = "pais", cascade = CascadeType.ALL)
>>  @JoinColumn(name = "pais_id")
>>  @Collection(child = true)
>>  public List<Provincia> getProvincias() {
>>    return provincias;
>>  }
>>
>>
>> Provincia---
>>
>>  @ManyToOne
>>  @Transient
>>  @InitialValue("pais.region")
>>  public Region getRegion() {
>>    return region;
>>  }
>>
>>
>>  @ManyToOne
>>  @PossibleValues("region.paises")
>>  public Pais getPais() {
>>    return pais;
>>  }
>>
>>
>> I want when choosing a region, only to drain the countries of that region,
>> but this I do not works.
>>
>> Any help thank you very much!
>> --
>> View this message in context: http://www.nabble.com/Help-dynamic-selects-tp24345072p24345072.html
>> Sent from the Trails - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

paises.composition.zip (83K) Download Attachment
paises.agregation.zip (69K) Download Attachment

Re: Help dynamic selects

by Juancevi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you very much Alejandro, to me was very helpful!!!

Saludos Juan!
 


Alejandro Scandroli-2 wrote:
Hey Juan!

I found the culprit.
There is a missing key in the editorMap in the archetype's
applicationContext.xml
Here it is:

                                <entry>
                                        <key>
                                                <value>
supportsExtension('org.trails.descriptor.annotation.PossibleValuesDescriptorExtension')
                                                        or
supportsExtension('org.trails.descriptor.annotation.InitialValueDescriptorExtension')
                                                </value>
                                        </key>
                                        <bean class="org.apache.tapestry.util.ComponentAddress">
                                                <constructor-arg index="0">
                                                        <value>trails:Editors</value>
                                                </constructor-arg>
                                                <constructor-arg index="1">
                                                        <value>filteredAssociation</value>
                                                </constructor-arg>
                                        </bean>
                                </entry>

You need that entry in place to make  @PosibleValues work.

About the mapping thing:

*  @ManyToOne and  @Transient are incompatibles
*  "mappedBy"  properties are readonly, you will need some extra code
to make them "editable"
*  It's best to use the Collection's inverse property together with the mappedBy
* If Provincia is a "child" collection (aka: composition) region &
pais properties should be readonly,  there is no point in using the
@PosibleValues there. If you want to use @PosibleValues Provincia
shouldn't be marked as "child" collection.

I'm sending you two mapping examples one with Provincia as a
composition and the other one with Provincia as an aggregation.

I hope it helps.
Saludos.
Alejandro.

On Mon, Jul 6, 2009 at 1:07 PM, Alejandro
Scandroli<ascandroli@codehaus.org> wrote:
> Hi Juan
>
> There is some inconsistencies in your mappings.
> But I tried to fix them to send you a working example and I found out
> that I can't make the PossibleValues annotation work outside the
> Simple example. So maybe there is something wrong or some
> configuration missing. I will try again tonight, and let you know.
>
> Saludos.
> Alejandro.
>
> PD:- I'm from Argentina too :)
>
>
> On Sun, Jul 5, 2009 at 7:20 PM, Juancevi<juancesarvillalba@gmail.com> wrote:
>>
>> Hello, my name is John I am from Argentina, I am newbie at trails, I have
>> nested combos mark the link
>> http://www.nabble.com/Enum-in-search-tt18317768.html#a18319874
>> but I can not be that I'm doing wrong.
>>
>>
>> Region---
>>
>>  @OneToMany(mappedBy = "region", cascade = CascadeType.ALL)
>>  @JoinColumn(name = "region_id")
>>  @Collection(child = false , allowRemove=false)
>>  public List<Pais> getPaises() {
>>    return paises;
>>  }
>>
>>
>> Pais---
>>
>>  @OneToMany(mappedBy = "pais", cascade = CascadeType.ALL)
>>  @JoinColumn(name = "pais_id")
>>  @Collection(child = true)
>>  public List<Provincia> getProvincias() {
>>    return provincias;
>>  }
>>
>>
>> Provincia---
>>
>>  @ManyToOne
>>  @Transient
>>  @InitialValue("pais.region")
>>  public Region getRegion() {
>>    return region;
>>  }
>>
>>
>>  @ManyToOne
>>  @PossibleValues("region.paises")
>>  public Pais getPais() {
>>    return pais;
>>  }
>>
>>
>> I want when choosing a region, only to drain the countries of that region,
>> but this I do not works.
>>
>> Any help thank you very much!
>> --
>> View this message in context: http://www.nabble.com/Help-dynamic-selects-tp24345072p24345072.html
>> Sent from the Trails - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

 
 
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email