Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Lukas Barina
Can I use search-container without a database ?
5 settembre 2012 23.10
Risposta

Lukas Barina

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 7 giugno 2012

Messaggi recenti

Hello,
I am kind of new in the liferay world.
I have some list of values I want to render it in jsp page with pagination features for the begining.
I saw how the liferay-ui-:search-container works, I really liked it and would like to use it for rendering of my list.

Do anybody know how to use liferay-ui:search-container if I don't use a database at all, is it even possible?
I have just a list of strings, let's say people names and I would like to render them in the search container.
I understoood how to define the search-container-results values form that list but I am lost how to prepare my
own model class for list
that is required by the search-container-row section.
I understood that's it is normally representation of some table, but in my case I don't use databases at all.


Thanks for any idea

Lukas
Jignesh Vachhani
RE: Can I use search-container without a database ?
5 settembre 2012 23.16
Risposta

Jignesh Vachhani

Punteggio: Liferay Master

Messaggi: 780

Data di Iscrizione: 10 marzo 2008

Messaggi recenti

Hi Lukas,

As per my understanding , you can definitely use search container using your modal class and setting properties.
For more about search container creation, you can check this Blog
Lukas Barina
RE: Can I use search-container without a database ?
5 settembre 2012 23.55
Risposta

Lukas Barina

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 7 giugno 2012

Messaggi recenti

Hi Jiqnesh,
thanks for your reply. I checked the blog so I found that this example the model class is
com.liferay.portlet.journal.model.JournalArticle
As I can see this class extends from JournalArticleModel which extends from BaseModel

So i my case where I have just a list of people names what would be the proper way to implement
such a model class?
I suppose the main necessary thing here is that my class People extends the liferay's BaseModel class
Still I'am not sure how my class People would look like, what class attributes I shoud define, what
constructor and methods it should contain. Do you think you can post some example of my class People,
it would help me to understand how it works.

Thanks Lukas
Amos Fong
RE: Can I use search-container without a database ?
6 settembre 2012 0.46
Risposta

Amos Fong

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1844

Data di Iscrizione: 7 ottobre 2008

Messaggi recenti

Hi Lukas,

You should be able to use it using standard java classes. Something like this should be fine (I didn't test this exact code).

 1<liferay-ui:search-container>
 2        <liferay-ui:search-container-results
 3            results="<%= stringList %>"
 4            total="<%= stringList.size() %>"
 5        />
 6
 7        <liferay-ui:search-container-row
 8            className="java.lang.String"
 9            modelVar="listMember"
10        >
Harish Kumar
RE: Can I use search-container without a database ?
6 settembre 2012 0.57
Risposta

Harish Kumar

Punteggio: Expert

Messaggi: 353

Data di Iscrizione: 31 luglio 2010

Messaggi recenti

Hi Lukas

Yes you can use search container without a database. Here is the sample code to iterate over arraylist of String using search container

 1
 2<%
 3   List<String> testList = new ArrayList<String>();
 4   for(int i=0;i<=50;i++)
 5   {
 6       testList.add("String " + i);
 7   }
 8%>
 9       <liferay-ui:search-container delta="10" emptyResultsMessage="No Items were found!!">
10        <liferay-ui:search-container-results results="<%=ListUtil.subList(testList, searchContainer.getStart(), searchContainer.getEnd())%>" total="${testList.size()}" />
11        <liferay-ui:search-container-row className="String" modelVar="data">
12            <liferay-ui:search-container-column-text name="name" value="<%=data %>" />
13        </liferay-ui:search-container-row>
14    </liferay-ui:search-container>



Regards,
Lukas Barina
RE: Can I use search-container without a database ?
6 settembre 2012 1.50
Risposta

Lukas Barina

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 7 giugno 2012

Messaggi recenti

Amos&Harish, that's great , thanks guys for the help !
Jay Trivedi
RE: Can I use search-container without a database ?
19 dicembre 2012 3.31
Risposta

Jay Trivedi

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 23 novembre 2012

Messaggi recenti

Hey Harish,
I have a simlilar form of question with different edge.
Lets say we can display a ArrayList<String> of UserName. But if i have an long array of ids and also i want to display that id. is that possible to display more than one list in searchContainer or that goes under limitation.

Here a sample code may help you to understand my problem in deep.

 1
 2<liferay-ui:search-container delta="10" emptyResultsMessage="Data-Not-Found">
 3        <liferay-ui:search-container-results
 4            results="<%=ListUtil.subList(usersNameList, searchContainer.getStart(), searchContainer.getEnd()) %>"
 5            total="<%=usersNameList.size() %>"
 6            <%int index = 0; %>
 7        />
 8            <liferay-ui:search-container-row
 9                className="java.lang.String"
10                modelVar="userToDisplay"
11            >
12                <liferay-ui:search-container-column-text
13                    name="UserName"
14                    value="<%=userToDisplay %>"
15                />
16               
17                <%-- <% for(int i=0;i<userId1.length;i++) { %> --%>
18                <liferay-ui:search-container-column-text>
19                    <input type="checkbox" name="userCheck" id="userCheck" value="<%[color=#8d0404]String.valueOf(userId1[index=index+1])[/color];%>"/>
20                </liferay-ui:search-container-column-text>
21                <%-- //<%} %> --%>
22            </liferay-ui:search-container-row>
23            <liferay-ui:search-iterator/>
24    </liferay-ui:search-container>


As you can see i am setting userid as value of checkbox, i want to add that userid as another list, so one more list in searchcontainerrow is that possible?
Any Suggestions or Alternatives?


Thanks and Regards,
Jay.
Mrinal kumar
RE: Can I use search-container without a database ?
31 gennaio 2013 19.51
Risposta

Mrinal kumar

Punteggio: New Member

Messaggi: 15

Data di Iscrizione: 30 gennaio 2013

Messaggi recenti

Hi...

I have tried this example..

but there is not data grid displayed... its empty.. : Its portlet code

code:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page import="java.util.*"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<portlet:defineObjects />

This is the <b>Dash Boardsss</b> portlet in View mode.




<%

List<String> testList = new ArrayList<String>();

for(int i=0;i<=50;i++)

{

testList.add("String " + i);

}

%>

<liferay-ui:search-container delta="10" emptyResultsMessage="No Items were found!!">

<liferay-ui:search-container-results results="<%=ListUtil.subList(testList, searchContainer.getStart(), searchContainer.getEnd())%>" total="${testList.size()}" />

<liferay-ui:search-container-row className="java.lang.String" modelVar="data">
<liferay-ui:search-container-column-text name="name" value="<%=data %>" />

</liferay-ui:search-container-row>

</liferay-ui:search-container>

This is the <b>END</b> portlet in View mode

Whats could be the issue?
Chirag Patadia
RE: Can I use search-container without a database ?
31 gennaio 2013 22.44
Risposta

Chirag Patadia

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 2 febbraio 2012

Messaggi recenti

Hi Jay,

You can achieve your requirement with below alternative.
You can keep your one Arraylist<String> which contains UserName as it is and for Ids why dont you create HashMap object with UserName string as key and Ids as value in HashMap.

By creating HashMap, you only need to fetch values from the Map in search container code where you are adding code for CheckBox.

Best Regards,
Chirag Patadia.
Jay Trivedi
RE: Can I use search-container without a database ?
1 febbraio 2013 22.46
Risposta

Jay Trivedi

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 23 novembre 2012

Messaggi recenti

Thanks Mrinal. emoticon