How to create service builder for liferay plugin project with maven

486 views Asked by At

I have Already create Liferay Plugin project. and maven install also over. it gives

 ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ---------------------------------------------------------------------
[INFO] Total time: 1:29.773s
[INFO] Finished at: Wed Jun 17 15:46:10 IST 2015
[INFO] Final Memory: 34M/151M
[INFO] -----------------------------.

But unable to add service builder.

When i try to add service builder
new->Liferay service builder.

It does not showing any plugin project.
Then how to add service builder?

2

There are 2 answers

0
Neeraj Gautam On BEST ANSWER

Frankly speaking Liferay-Maven combination is not so fully supported by Liferay IDE in eclipse. Originally Liferay IDE has been created for only ANT support but since maven support has been introduced there are many things missing.

This issue which you have raised is same for following options as well.

  1. JSF Portlet
  2. Layout
  3. Theme
  4. Service Builder

This is not an issue for following options

  1. Hook
  2. Portlet
  3. Vaadin Portlet

So, best way is to generate new service builder through maven archetypes supported for specific liferay version. E.g com.liferay.maven.archetypes:liferay-servicebuilder-archetype:6.2.1 for liferay 6.2.1 GA2 version.

2
UnP On

If you want to add a vaadin application to existing liferay portlet then create new LIFERAY-VAADIN project and there you can use "You can continue to use ServiceBuilder as you always have, and retrieve data from your services using XXXXXServiceUtil (or XXXXXLocalServiceUtil)." You may also want to check here, and here.

For example here is one DatabaseUtil class from vaadin.

import java.awt.List;
import java.util.ArrayList;

import com.vaadin.data.util.HierarchicalContainer;

public class DatabaseUtil {
  public static HierarchicalContainer fillTree_db() {
    HierarchicalContainer container = new HierarchicalContainer();
    ArrayList < ArrayList < String >> treeNodes = new ArrayList < ArrayList < String >> ();

    try {

      List < TREEVIEW > nodes = TREEVIEWLocalServiceUtil.getAllNodes();

      for (TREEVIEW node: nodes) {
        String nodename = node.getNodename();
        ArrayList < String > row = new ArrayList < String > ();
        row.add(String.valueOf(node.getNodeid()));
        row.add(node.getNodename());
        row.add(String.valueOf(node.getRootid()));
        container.addItem(nodename);
        treeNodes.add(row);
      }

      for (int i = 0; i < treeNodes.size(); i++) {
        int root = 0;
        root = Integer.parseInt(treeNodes.get(i).get(2));

        if (root != 0)
          container.setParent(treeNodes.get(i).get(1),
            treeNodes.get(root - 1).get(1));
      }

    } catch (Exception e) {
      System.err.println("Exception: " + e.getMessage());
    } finally {}
    return container;
  }

}