>I have a online library where I need to display book title along with Author and separate the variable >with a string (e.g ":" or "by")
>
><reference-view reference="book">
> <descriptions-list description-properties="title, author.firstName, author.secondName"/>
></reference-view>
Thi sis very interesting requirement and very usefull one.
I think that it is possible to modify OpenXava to do this. I imagine something like this:
<descriptions-list description-properties="${title} by ${author.firstName} ${author.secondName}"/>
or
<descriptions-list description-properties="${title} : ${author.firstName} ${author.secondName}"/>
Or some other way to distinguish properties from strings.
Can you guide how to develop it?
Kind regards,
Trifon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> Or some other way to distinguish properties from strings.
Your way is good, and I think that natural for an OX developer.
Maybe to use other attribute, perhaps 'description-expression' or so,
would be a good idea. What do you think ?
> Can you guide how to develop it?
Of course.
The code for concatenating the description of description list
is in the DescriptionsCalculator class. Have a look to it,
and try to modify it in order to support your suggested syntax.
I expect your question about this class.
After this works, we can consider using 'description-expression',
this will involve to modify the dtd and parser.
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>Maybe to use other attribute, perhaps 'description-expression' or so,
>would be a good idea. What do you think ?
'description-expression' is good name.
>The code for concatenating the description of description list
>is in the DescriptionsCalculator class. Have a look to it,
>and try to modify it in order to support your suggested syntax.
Thank you, Javi!
I have a question:
<descriptions-list description-properties="${title} by ${author.firstName} ${author.secondName}"/>
How to translate 'by' word?
Kind regards,
Trifon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> What about message-id?
On the one hand it's good because it's clear that the id is from message i18n file;
but on the other, this is not for translating a message but each description in the list, it can be confused.
Other options can be:
description-i18n-id
message-id-for-description
description-message-id
Do you like some of them ? Other better options ?
A intuitive name is important, because most programmers use the attributes
by its names (with the help of the IDE autocompletion) without go to the
documentation.
Anyways, you can start to implement the feature, meanwhile we can find
a better name for the attribute.
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Javi
Is it possible to add text to a description list.
I have a online library where I need to display book title along with Author and separate the variable with a string (e.g ":" or "by")
<reference-view reference="book">
<descriptions-list description-properties="title ,author.firstName, author.secondName"/>
</reference-view>
How to do this?
Thanking you
Janesh
Hi Javi,
>I have a online library where I need to display book title along with Author and separate the variable >with a string (e.g ":" or "by")
>
><reference-view reference="book">
> <descriptions-list description-properties="title, author.firstName, author.secondName"/>
></reference-view>
Thi sis very interesting requirement and very usefull one.
I think that it is possible to modify OpenXava to do this. I imagine something like this:
<descriptions-list description-properties="${title} by ${author.firstName} ${author.secondName}"/>
or
<descriptions-list description-properties="${title} : ${author.firstName} ${author.secondName}"/>
Or some other way to distinguish properties from strings.
Can you guide how to develop it?
Kind regards,
Trifon
Hi Trifon,
> Or some other way to distinguish properties from strings.
Your way is good, and I think that natural for an OX developer.
Maybe to use other attribute, perhaps 'description-expression' or so,
would be a good idea. What do you think ?
> Can you guide how to develop it?
Of course.
The code for concatenating the description of description list
is in the DescriptionsCalculator class. Have a look to it,
and try to modify it in order to support your suggested syntax.
I expect your question about this class.
After this works, we can consider using 'description-expression',
this will involve to modify the dtd and parser.
Cheers
Javi
Hi Javi,
>Maybe to use other attribute, perhaps 'description-expression' or so,
>would be a good idea. What do you think ?
'description-expression' is good name.
>The code for concatenating the description of description list
>is in the DescriptionsCalculator class. Have a look to it,
>and try to modify it in order to support your suggested syntax.
Thank you, Javi!
I have a question:
<descriptions-list description-properties="${title} by ${author.firstName} ${author.secondName}"/>
How to translate 'by' word?
Kind regards,
Trifon
Hi Trifon,
> How to translate 'by' word?
Good question!
I suggest you another solution more focused on i18n.
That is
<descriptions-list
description-properties="title, author.firstName, author.secondName"
pattern-id="descriptions_list_book_title"
/>
And in YourApplication-messages_en.properties you have:
descriptions_list_book_title={0} by {1} {2}
pattern-id is the identifier used in i18n files. It's not clear to me
if this is a good name.
Do you like this solution ?
I think it's easier to implement, but the more important goal
it's to be intuitive.
Cheers
Javi
Hi Javi,
><descriptions-list description-properties="title, author.firstName, author.secondName"
>pattern-id="descriptions_list_book_title"
>/>
>
>And in YourApplication-messages_en.properties you have:
>descriptions_list_book_title={0} by {1} {2}
i think that this is good way.
>pattern-id is the identifier used in i18n files. It's not clear to me
>if this is a good name.
>
>Do you like this solution ?
What about message-id?
Kind regards,
Trifon
Hi Trifon,
> What about message-id?
On the one hand it's good because it's clear that the id is from message i18n file;
but on the other, this is not for translating a message but each description in the list, it can be confused.
Other options can be:
description-i18n-id
message-id-for-description
description-message-id
Do you like some of them ? Other better options ?
A intuitive name is important, because most programmers use the attributes
by its names (with the help of the IDE autocompletion) without go to the
documentation.
Anyways, you can start to implement the feature, meanwhile we can find
a better name for the attribute.
Cheers
Javi
Hi Javi,
>Other options can be:
>description-i18n-id
>message-id-for-description
>description-message-id
>
>Do you like some of them? Other better options?
i like description-message-id.
thank's for suggestions.
Kind regards,
Trifon
Hi Janesh,
> How to do this?
Maybe this works for you:
<component name="Book">
<entity>
...
<property name="authorFullName" type="String" size="25">
<calculator class="org.openxava.calculators.ConcatCalculator">
<set property="string1" from="author.firstName"/>
<set property="separator" value=" "/>
<set property="string2" from="author.secondName"/>
</calculator>
</property>
<property name="fullTitle" type="String" size="60">
<calculator class="org.openxava.calculators.ConcatCalculator">
<set property="string1" from="title"/>
<set property="separator" value=" by "/>
<set property="string2" from="authorFullName"/>
</calculator>
</property>
</entity>
...
</component>
<component ... >
<view>
<reference-view reference="book">
<descriptions-list description-properties="fullTitle"/>
</reference-view>
</view>
</component>
This is a solution that you can use now.
Perhaps Trifon will develop a more succint solution.
Cheers
Javi