CRUD, ManyToOne, Sorting

99 visninger
Gå til det første ulæste opslag

Илья Скорик

ulæst,
19. okt. 2011, 05.43.3619.10.2011
til play-framework
I have this code in Article Model:

@ManyToOne(fetch = FetchType.EAGER)
public Category category;

In one Article can be only one Category. And when editing Article
properties in CRUD, I see a list of possible Categories. But this list
is not sorted alphabetically! How I can sort it?

Mikael

ulæst,
19. okt. 2011, 07.08.0919.10.2011
til play-fr...@googlegroups.com
Have you tried something like this in your Article:

@OrderBy("categoryName DESC") 
List<Category> categories

Илья Скорик

ulæst,
19. okt. 2011, 08.01.1219.10.2011
til play-fr...@googlegroups.com
I can't do that. Category is a single object, not list.

2011/10/19 Mikael <mikael...@gmail.com>:


> Have you tried something like this in your Article:
> @OrderBy("categoryName DESC")
> List<Category> categories
>

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/BC0uinvpBtAJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

--
С уважением, Илья Скорик
Yours faithfully, Ilya Skorik

Илья Скорик

ulæst,
19. okt. 2011, 10.53.3719.10.2011
til play-fr...@googlegroups.com
Solution:

In relationField tag add:

%{
sortedArray = _field.choices
try {
Collections.sort(sortedArray);
} catch (Exception ex) {
}
%}

And change:

%{ _field.choices.each() { }%

to

%{ sortedArray.each() { }%

Than add Comparable interface to Model

19 октября 2011 г. 16:01 пользователь Илья Скорик <il...@skorik.me> написал:

Aishwarya Singhal

ulæst,
19. okt. 2011, 12.30.5719.10.2011
til play-framework
i think i would prefer "order by" on the database query vis-a-vis
sorting in application code. can you perhaps do a HQL ?

On Oct 19, 7:53 pm, Илья Скорик <i...@skorik.me> wrote:
> Solution:
>
> In relationField tag add:
>
> %{
>         sortedArray = _field.choices
>         try {
>             Collections.sort(sortedArray);
>         } catch (Exception ex) {
>         }
> %}
>
> And change:
>
> %{ _field.choices.each() { }%
>
> to
>
> %{ sortedArray.each() { }%
>
> Than add Comparable interface to Model
>
> 19 ÏËÔÑÂÒÑ 2011šÇ. 16:01 ÐÏÌØÚÏ×ÁÔÅÌØ éÌØÑ óËÏÒÉË <i...@skorik.me> ÎÁÐÉÓÁÌ:
>
>
>
>
>
>
>
>
>
> > I can't do that. Category is a single object, not list.
>
> > 2011/10/19 Mikael <mikael.bel...@gmail.com>:
> >> Have you tried something like this in your Article:
> >> @OrderBy("categoryName DESC")
> >> List<Category> categories
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "play-framework" group.
> >> To view this discussion on the web visit
> >>https://groups.google.com/d/msg/play-framework/-/BC0uinvpBtAJ.
> >> To post to this group, send email to play-fr...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> play-framewor...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/play-framework?hl=en.
>
> > --
> > ó Õ×ÁÖÅÎÉÅÍ, éÌØÑ óËÏÒÉË
> > Yours faithfully, Ilya Skorik
>
> --
> ó Õ×ÁÖÅÎÉÅÍ, éÌØÑ óËÏÒÉË
> Yours faithfully, Ilya Skorik

Илья Скорик

ulæst,
19. okt. 2011, 17.20.5119.10.2011
til play-fr...@googlegroups.com
This is CRUD module, where possible values for fields selected
dynamically. In this case by Choises interface:

public List<Object> getChoices() {
return property.choices.list();
}

I found no way to pass parameters to this method without significant
modifications to the CRUD and Play code.

2011/10/19 Aishwarya Singhal <asing...@gmail.com>:

--

Svar alle
Svar til forfatter
Videresend
0 nye opslag