Fórum

JSON

abhishek kumar, modificado 7 Anos atrás.

JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
Hello folks,

Well i have a custom portlet , one dropdown menu items is there. and i have a Products.json file .

So comming back exactly to requirement when i clicked one menu items likewise PRODUCT then .
the whatever the details in products.json likewise Name (For example- iphone , dell) So That things i want to display when i clicked on product item.


I dodnt know exactly how to do this, if i am not wrong to explain kindly tell me any positive things, how exactly to achieve this..??


Regards
Abhishek
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: JSON

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Abhishek,

It sounds to me from what you are describing that you need to register a click event on the drop down menu DOM element. When it is clicked you need to have that javascript handler fire and in that handler make an ajax call (serve resource method in your portlet) with something that can be used to filter the details in the JSON file. The serve resource method in your portlet will read the json file (assuming, again, it is packaged with your portlet) -- get the details to be displayed and pass them back. Your same JS handler can then update the DOM with the details from the response.

One thing I am not clear on. The text in the JSON file, do you need to show ALL of it all of the time in the drop down? or just part of the JSON in the drop down?
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
Thank you andrew

updated thing is here!

now i am able to fetch the json file and data i can able to display in the console. but i am working on java projects not in liferay.

the results i can able to diplay in console now how can i display this output in liferay popup means when i clicked on dropdown then the console output display in liferay popup.?????
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: JSON

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Let me see if I understand what you said.

You have created a separate Java program (let's call it HelloWorld) and in that program you are able to load your JSON file and use System.out or a Logger or something to print the text to stdout. So you have validated that you can find the file, read the contents and then spit them out.

But you need to do this in Liferay. The good news is that the code to read the file contents you can reuse in the portlet code. You could even use the spitting out to log the contents (in debug mode say).

Soooo -- to do this in Liferay, maybe tell us a bit more about your project?

1. Is this an Liferay MVC portlet?

2. Can you provide the Portlet Class code?

3. Can you provide the JSP for the view?
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
Thank you Andrew Jardine:

Soooo -- to do this in Liferay, maybe tell us a bit more about your project?


yes sir that is correct first i am using standalone after that i move to liferay portlet , for display purpose i am using jsp and displaying the result in popup that is javascript alert message.

Now the requirement is little bit change i already told that for display i am using my json file that is product.json.

now in the popup the free text query would be that is integrated by NLP API in Liferay.

The things i have to do :-
1:- It is integrated by NLP api in Liferay.
2:- when the person will search like "How many having Iphone" in free text query it will display as per the search .


Is any idea or any demo for refrence how exactly i will happened??

Regards
Abhishek
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: JSON

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Assuming that NLP is natural language processing here is what I understand you need. Sorry Abhishek, I realize that you are actively working on this but keeping up with your updates and understanding what you are trying to do is very difficult to assess from reading between the lines. Here is what I understand.

1. You have a search field... or some kind of user input.
2. Either as the user types, or after they submit a value you want to use an NLP to perform some kind of search.
3. The user is displayed the results
4. The user selects an item from the results
5. The record they choose is tied to a json file that contains the details to display to them in a popup.
6. All of this is done from a Liferay MVC portlet that is using JSPs for its templating

Is this what you are trying to accomplish?
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
yes sir totally correct ..
this is the thing i want to achieve...
Kindly tell me , i am reallyie stuck ?
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: JSON

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
You certainly drew the short straw when the tasks were being handed out then because, if you are learning Liferay, you got a challenging problem to solve. Liferay does a lot of the hard stuff for you though but I certainly would not give this to a beginner team member.

The easiest way to solve this one is to tackle it one little piece at a time. If you try to do the whole end to end you're definitely going to be overwhelmed. I'm happy to guide you through the process but I need to know where you are at right now.

1. Have you created your portlet? if so, what is the name of it -- most notable the name of the Java Class you are using for the portlet. You can find it in the portlet.xml file for your project. If you haven't defined a class, then the answer is likely MVCPortlet (which Liferay provides)

2. Which NLP are you using? (include a link to the site please so I can see it).
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
yes sir till now i had created a Liferay MVC portlet then name i had given project name is NlpApi and class name is Nlp.

for move forward to this i had referred this link LINK for NLP
i had downloaded 4 jar files and put it in my Portlet .(apache-opennlp-1.5.3-bin.zip).

After that i am not getting any exact idea how exactly to start ??

Regards
Abhishek
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: JSON

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Ok -- my first recommendation is to use a name that follows convention. So if you have in your portlet.xml ...

...
<portlet-class>com.xxx.yyy.liferay.portlet.Nlp</portlet-class>
...


I would recommend changing that to something a little more descriptive and conventional. So if this portlet is supposed to show products then it's more common to use ProductPortlet. If you want to indicate that it uses NLP, then maybe something like NLPProductPortlet. Package structure is often organization dependent but, personally, I like to follow Liferay convention and organize my portlets under a portlet folder. So maybe something like this --

...
<portlet-class>com.xxx.yyy.liferay.portlet.nlpproduct.NLPProductPortlet</portlet-class>
...


Now, one of the files that is created for your is a view.jsp. In this file, start by adding the form with the text field. If you want to stay true to LR, then you should use the AUI taglibs so that you have an <aui:form/> with <aui:../> child nodes. I'm not going to give you the code on how to do this or you'll never learn, so go get that part done and then come back. In your response, if you can, attach the portlet plugin project so I can follow along.
abhishek kumar, modificado 7 Anos atrás.

RE: JSON

Regular Member Postagens: 138 Data de Entrada: 17/08/15 Postagens Recentes
Thank you for the reply sir , i will try this !
Avinash kumar, modificado 6 Anos atrás.

RE: JSON

New Member Postagens: 19 Data de Entrada: 10/07/17 Postagens Recentes
Hi All ,

I have a requirement where I need to expose all the webcontent present in the liferay to a JSON format
how we can do this ???

Can anyone help in this ?
thumbnail
Olaf Kock, modificado 6 Anos atrás.

RE: JSON

Liferay Legend Postagens: 6403 Data de Entrada: 23/09/08 Postagens Recentes
Avinash kumar:
I have a requirement where I need to expose all the webcontent present in the liferay to a JSON format
how we can do this ???


http://localhost:8080/api/jsonws

The services you look for start with Journal*