Re: Entities referencing domain style Entities

2008-12-13 Thread nillehammer
Hi Luther,

an alternative to contributing a DataTypeAnalyzer you could also use the
 annotation DataType on getters in your Entities so instead of doing

public static void contributeDefaultDataTypeAnalyzer
MappedConfigurationClass, String configuration)
{
  configuration.add(Category.class, category);
}

you could do
public class User
{
...
  @DataType(category) // DataType needn't be analyzed, because you
// provide Tapestry with necessary information.
  public Category getCategory() {
return this.category;
  }
...
}

lutherbaker schrieb:
 Thanks Uli!
 
 
 
 Ulrich Stärk wrote:
 Luther Baker schrieb:
 I have an entity that contains another entity - but this time, the
 contained
 entity table is quite finite - say, 10 rows.

 public class Category
 {
   private String name;
 }

 public class User
 {
private String firstName;
private String lastName;
private Category category;
 }

 and in this case, I'd like to render firstName, lastName and a DROP DOWN
 or
 some type of picker from existing Categories.

 Would I need to create my own t:form ... and possibly use a t:BeanEditor
 with a custom drop down/picker -- or is this type of idiom encapsulated
 in a
 Tapestry component already?

 Thanks much,

 -Luther

 Indeed you'll have to create a BeanBlockContribution and contribute it to
 the BeanBlockSource 
 service. This contribution tells tapestry where to look for the component,
 that is responsible for 
 rendering your type. Additionally you'll have to contribute your type to
 the DefaultDataTypeAnalyzer 
 service. That could look something along the lines of

 public static void contributeDefaultDataTypeAnalyzer(
  MappedConfigurationClass, String configuration)
 {
  configuration.add(Category.class, category);
 }

 public static void
 contributeBeanBlockSource(ConfigurationBeanBlockContribution
 configuration)
 {
  configuration.add(new BeanBlockContribution(category,
 AppPropertyEditBlocks, category, 
 true));
 }

 AppPropertyEditBlocks is the name of a page that contains a component with
 the id category that is 
 responsible for rendering your category. In your case this would be a
 select component:

 @Environmental
 private PropertyEditContext context;

 @Component(parameters =
 { value=context.propertyValue, label=prop:context.label,
model=prop:categoryModel, encoder=prop:categoryEncoder,
clientId=prop:context.propertyId, validate=prop:validator })
 private Select category;

 @Inject
 private PropertyAccess propertyAccess;

 @SuppressWarnings({ unused, unchecked })
 public FieldValidator getValidator()
 {
  return context.getValidator(category);
 }

 public PropertyEditContext getContext() { return context; }

 public SelectModelCategory getCategoryModel()
 {
  ...
 }

 public ValueEncoderCategory getCategoryEncoder()
 {
  ...
 }
 with the corresponding .tml:

 div xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;
t:block t:id=category
  t:label for=category /
  t:select t:id=category /
/t:block
 /div

 I believe that there is also some information about this on the wiki,
 check it out!

 HTH,

 Uli

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org



 

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Entities referencing domain style Entities

2008-12-12 Thread lutherbaker

Is this just a bad question?



Luther Baker wrote:
 
 I have an entity that contains another entity - but this time, the
 contained
 entity table is quite finite - say, 10 rows.
 
 public class Category
 {
   private String name;
 }
 
 public class User
 {
private String firstName;
private String lastName;
private Category category;
 }
 
 and in this case, I'd like to render firstName, lastName and a DROP DOWN
 or
 some type of picker from existing Categories.
 
 Would I need to create my own t:form ... and possibly use a t:BeanEditor
 with a custom drop down/picker -- or is this type of idiom encapsulated in
 a
 Tapestry component already?
 
 Thanks much,
 
 -Luther
 
 

-- 
View this message in context: 
http://www.nabble.com/Entities-referencing-domain-style-Entities-tp20948001p20982590.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Entities referencing domain style Entities

2008-12-12 Thread Ulrich Stärk

Luther Baker schrieb:

I have an entity that contains another entity - but this time, the contained
entity table is quite finite - say, 10 rows.

public class Category
{
  private String name;
}

public class User
{
   private String firstName;
   private String lastName;
   private Category category;
}

and in this case, I'd like to render firstName, lastName and a DROP DOWN or
some type of picker from existing Categories.

Would I need to create my own t:form ... and possibly use a t:BeanEditor
with a custom drop down/picker -- or is this type of idiom encapsulated in a
Tapestry component already?

Thanks much,

-Luther



Indeed you'll have to create a BeanBlockContribution and contribute it to the BeanBlockSource 
service. This contribution tells tapestry where to look for the component, that is responsible for 
rendering your type. Additionally you'll have to contribute your type to the DefaultDataTypeAnalyzer 
service. That could look something along the lines of


public static void contributeDefaultDataTypeAnalyzer(
MappedConfigurationClass, String configuration)
{
configuration.add(Category.class, category);
}

public static void 
contributeBeanBlockSource(ConfigurationBeanBlockContribution configuration)
{
configuration.add(new BeanBlockContribution(category, AppPropertyEditBlocks, category, 
true));

}

AppPropertyEditBlocks is the name of a page that contains a component with the id category that is 
responsible for rendering your category. In your case this would be a select component:


@Environmental
private PropertyEditContext context;

@Component(parameters =
{ value=context.propertyValue, label=prop:context.label,
  model=prop:categoryModel, encoder=prop:categoryEncoder,
  clientId=prop:context.propertyId, validate=prop:validator })
private Select category;

@Inject
private PropertyAccess propertyAccess;

@SuppressWarnings({ unused, unchecked })
public FieldValidator getValidator()
{
return context.getValidator(category);
}

public PropertyEditContext getContext() { return context; }

public SelectModelCategory getCategoryModel()
{
...
}

public ValueEncoderCategory getCategoryEncoder()
{
...
}
with the corresponding .tml:

div xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;
  t:block t:id=category
t:label for=category /
t:select t:id=category /
  /t:block
/div

I believe that there is also some information about this on the wiki, check it 
out!

HTH,

Uli

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Entities referencing domain style Entities

2008-12-12 Thread lutherbaker

Thanks Uli!



Ulrich Stärk wrote:
 
 Luther Baker schrieb:
 I have an entity that contains another entity - but this time, the
 contained
 entity table is quite finite - say, 10 rows.
 
 public class Category
 {
   private String name;
 }
 
 public class User
 {
private String firstName;
private String lastName;
private Category category;
 }
 
 and in this case, I'd like to render firstName, lastName and a DROP DOWN
 or
 some type of picker from existing Categories.
 
 Would I need to create my own t:form ... and possibly use a t:BeanEditor
 with a custom drop down/picker -- or is this type of idiom encapsulated
 in a
 Tapestry component already?
 
 Thanks much,
 
 -Luther
 
 
 Indeed you'll have to create a BeanBlockContribution and contribute it to
 the BeanBlockSource 
 service. This contribution tells tapestry where to look for the component,
 that is responsible for 
 rendering your type. Additionally you'll have to contribute your type to
 the DefaultDataTypeAnalyzer 
 service. That could look something along the lines of
 
 public static void contributeDefaultDataTypeAnalyzer(
  MappedConfigurationClass, String configuration)
 {
  configuration.add(Category.class, category);
 }
 
 public static void
 contributeBeanBlockSource(ConfigurationBeanBlockContribution
 configuration)
 {
  configuration.add(new BeanBlockContribution(category,
 AppPropertyEditBlocks, category, 
 true));
 }
 
 AppPropertyEditBlocks is the name of a page that contains a component with
 the id category that is 
 responsible for rendering your category. In your case this would be a
 select component:
 
 @Environmental
 private PropertyEditContext context;
 
 @Component(parameters =
 { value=context.propertyValue, label=prop:context.label,
model=prop:categoryModel, encoder=prop:categoryEncoder,
clientId=prop:context.propertyId, validate=prop:validator })
 private Select category;
 
 @Inject
 private PropertyAccess propertyAccess;
 
 @SuppressWarnings({ unused, unchecked })
 public FieldValidator getValidator()
 {
  return context.getValidator(category);
 }
 
 public PropertyEditContext getContext() { return context; }
 
 public SelectModelCategory getCategoryModel()
 {
  ...
 }
 
 public ValueEncoderCategory getCategoryEncoder()
 {
  ...
 }
 with the corresponding .tml:
 
 div xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;
t:block t:id=category
  t:label for=category /
  t:select t:id=category /
/t:block
 /div
 
 I believe that there is also some information about this on the wiki,
 check it out!
 
 HTH,
 
 Uli
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Entities-referencing-domain-style-Entities-tp20948001p20983899.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Entities referencing domain style Entities

2008-12-10 Thread Luther Baker
I have an entity that contains another entity - but this time, the contained
entity table is quite finite - say, 10 rows.

public class Category
{
  private String name;
}

public class User
{
   private String firstName;
   private String lastName;
   private Category category;
}

and in this case, I'd like to render firstName, lastName and a DROP DOWN or
some type of picker from existing Categories.

Would I need to create my own t:form ... and possibly use a t:BeanEditor
with a custom drop down/picker -- or is this type of idiom encapsulated in a
Tapestry component already?

Thanks much,

-Luther