Hola Hernán
responses inline
On Sun, Dec 21, 2008 at 9:30 PM, El Acuariano <
acuariano@...> wrote:
> Hi all,
> (...)
> Is there any reason why the Javadocs don't have more
> information on intended use?
Mostly my laziness :( and also writter's block. I'm sorry, I know I
should write more and better documentation but I always end up
postponing it so I can code some more (and I know is wrong).
> I found in the "Trails gotchas" page an old link to the examples in the
> repository. It points to the 1.0 SNAPSHOT version
> in
http://trails.inspiring.nl/svn/trunk/trails/examples/. It would be nice
> to update it to point
> to
http://svn.codehaus.org/trails/tags/trails-1.2/examples.
>
fixed. Remember it's a wiki, if you found something like this you
help us editing it your self.
> - I need to fill-in an incremental invoice number. It should be editable for
> flexibility, but when creating a new invoice it should be initialized to the
> current invoice number. How can I set the initial value for a new invoice?
There is a builder pattern implementation. But I just realize that
in Trails 1.2.x there is no way to contribute your builder
(org.trails.builder.Builder) to the builder director. Take a look at
it (org.trails.builder.BuilderDirector), if that is what you need I
can quickly fix it to allow contributions to the map.
> - Each line of the invoice correspond to a product. I need that the unit
> price of the line be independent of the product, to avoid changing old
> invoices if a product price changes. Also, it should be editable, to reflect
> special prices (promotions, etc.). When editing a line, if I change the
> product, the unit price for the line should change to reflect the current
> price of the new product. It would be nice to make it work in the browser,
> using JavaScript. I need to create an edition page to do this, right? How
> can I get all available products and their prices to be usable with JS? I
> would add JSON containing the products to the page so I can access them, but
> I don't understand enough of the Trails "plumbing" to really know how to do
> it.
You don't need to use custom javascript to do this. Tapestry (and
Trails) can take of this for you.
You need a custom edit page with both template & java code and then
some Tapestry love :)
Add this blocks in your invoice line edit page template (I've used
category instead of product):
<div jwcid="category@Block">
<li>
<label><span jwcid="@Insert"
value="ognl:classDescriptor.getPropertyDescriptor('category').displayName"/></label>
<select jwcid="categoryField@trails:AssociationSelect"
value="ognl:model.category"
class="field select medium"
propertyDescriptor="ognl:classDescriptor.getPropertyDescriptor('category')"/>
</li>
</div>
<div jwcid="price@Block">
<li>
<label><span jwcid="@Insert"
value="ognl:priceDescritor.displayName"/></label>
<input jwcid="priceField@TextField" value="ognl:model.price"
class="field text medium"
translator="ognl:validatorTranslatorService.getTranslator(priceDescritor)"
validator="ognl:validatorTranslatorService.getValidator(priceDescritor)"
/>
</li>
</div>
Then add this code to you invoice line edit page java code (remember
to extend from HibernateEditPage).
@InjectObject("service:trails.core.ValidatorTranslatorService")
public abstract ValidatorTranslatorService getValidatorTranslatorService();
public IPropertyDescriptor getPriceDescritor()
{
return getClassDescriptor().getPropertyDescriptor("price");
}
@EventListener(targets = "categoryField", events = "onchange")
public void onCategoryFieldSelectOption(IRequestCycle cycle)
{
InvoiceLine model = (InvoiceLine) getModel();
if (model.getCategory() != null)
{
model.setPrice(model.getCategory().getPrice());
cycle.getResponseBuilder().updateComponent("priceField");
}
}
That's it. That's all you need.
More docs:
http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html> - For several object I need to be able to "freeze" some properties. For
> example, an invoice could have a "status" field. When the status changes to
> "approved" then no more edition is allowed. Is there a nice and simple way
> to do this?
The first thing I can think of is to have a block for that property
and then check for the "approved" status in an @If component.
<div jwcid="status@Block">
<span jwcid="@If" condition="CHECK FOR STATUS HERE">
<span jwcid="@trails:SimplePropertyEditor" property="status"/>
</span><span jwcid="@Else">
SOMETHING ELSE
</span>
</div>
> Thanks,
> Hernán
>
Felices fiestas!
Saludos!
Alejandro.
--
Alejandro Scandroli -
http://weblog.amneris.es/Amneris: We build process-driven web applications.
http://www.amneris.es---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email