Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Jari Fredriksson
How to read announcements in Liferay 6.x?
5 de Outubro de 2010 12:26
Resposta

Jari Fredriksson

Ranking: New Member

Mensagens: 23

Data de entrada: 14 de Setembro de 2010

Mensagens recentes

I need to get my hands really dirty with Liferay 6.x soon, but my first test drive is just to create a portlet that reads the three latest announcements, and put them to the screen.

I tried to copy jsp code from Liferay announcements portlet, but that way was doomed. My own portlet runs as its own portlet war, and has access only to the portlet-service.jar.

I have tried to look at the JavaDoc, and I see lots of classes, documented that "you must not use this" emoticon

So what classes to use? Anyone done this kind of a simple portlet, and has pointers?

I would love to get the book, but I think it is written for Liferay 5.x?
Jelmer Kuperus
RE: How to read announcements in Liferay 6.x?
5 de Outubro de 2010 13:02
Resposta

Jelmer Kuperus

Ranking: Liferay Legend

Mensagens: 1192

Data de entrada: 10 de Março de 2010

Mensagens recentes

probably something like

1LinkedHashMap<Long, long[]> scopes = AnnouncementsUtil.getAnnouncementScopes(user.getUserId());
2
3
4List<AnnouncementsEntry> entries = AnnouncementsEntryLocalServiceUtil.getEntries(user.getUserId(), scopes, false, AnnouncementsFlagConstants.NOT_HIDDEN, 0, 3);



There are a number of books out there

the packt development books are for 5.x,
the apress book is for 5.x too
liferay in action & portlets in action cover 6.x
the packt book about using liferay covers 6.x
Jari Fredriksson
RE: How to read announcements in Liferay 6.x?
6 de Outubro de 2010 00:46
Resposta

Jari Fredriksson

Ranking: New Member

Mensagens: 23

Data de entrada: 14 de Setembro de 2010

Mensagens recentes

AnnouncementUtil is not available. It does not belong to portal-service.jar

Thanks for the book recommendations!
Jari Fredriksson
RE: How to read announcements in Liferay 6.x?
6 de Outubro de 2010 03:31
Resposta

Jari Fredriksson

Ranking: New Member

Mensagens: 23

Data de entrada: 14 de Setembro de 2010

Mensagens recentes

I tried code:

 1
 2<%
 3LinkedHashMap<Long, long[]> scopes = null; // AnnouncementsUtil.getAnnouncementScopes(user.getUserId());
 4
 5List<AnnouncementsEntry> results = null;
 6
 7int flagValue = AnnouncementsFlagConstants.NOT_HIDDEN;
 8
 9// Get 3 last entries
10results = AnnouncementsEntryLocalServiceUtil.getEntries(
11        user.getUserId(), scopes, false, flagValue, 0, 3);
12
13for (int i = 0; i < results.size(); i++) {
14    AnnouncementsEntry entry = results.get(i);
15
16    String className = StringPool.BLANK;
17
18    if (i == 0) {
19        className += " first";
20    }
21
22    if ((i + 1) == results.size()) {
23        className += " last";
24    }
25%>


But it somehow causes MySQL syntax error. While I debugged, I saw that it was trying to get HIDDEN announces, no matter that the flagValue is NOT_HIDDEN. And then I took the SQL statement it generated, and tried it in MySQL query browser, it passed OK there. Then I tried the statement in Netbeans via JDBC, if it was a JDBC problem, but no, it works there too.

Then I changed the getEntries() in format

1
2results = AnnouncementsEntryLocalServiceUtil.getAnnouncementsEntries(0, 3);


And that works! But I probably will need a more fine grained getter, to get different types of announcements...