Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » REST frontend questions(Questions for building a REST frontend)
REST frontend questions [message #1838890] Mon, 08 March 2021 09:42 Go to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Hi there everyone,

I've been working on the project building menus, pages and forms and so far so good. I am very pleased with the default functionality in Eclipse Scout 10 tables. They are really good.

The next steps for me are what Andre advised in his response here https://www.eclipse.org/forums/index.php?t=msg&th=1106874&goto=1837778&#msg_1837778

Following that threw up the following questions:

a) I want to start creating the various entities for the application. I have been reading Chapter 16 Data Objects in the Scout Technical Guide. I created an entity for contacts but I'm not sure if what I did is correct:

public class ContactDo extends DoEntity {

  public DoValue<String> contactId() {
    return doValue("contactid");
  }

  public DoValue<String> firstName() {
    return doValue("firstname");
  }

  public DoValue<String> lastName() {
    return doValue("lastname");
  }

  public DoValue<String> gender() {
    return doValue("gender");
  }

  public DoValue<String> jobTitle() {
    return doValue("jobtitle");
  }

  public DoValue<String> telephone() {
    return doValue("telephone");
  }

  public DoValue<String> portable() {
    return doValue("portable");
  }

  public DoValue<String> email() {
    return doValue("email");
  }

  public DoValue<String> contactType() {
    return doValue("contacttype");
  }
}


b) My server sends JSON documents with key values in French so for instance, instead of "firstname", it will send "prenom". Should I have return doValue("prenom") instead of return doValue("firstname") and so on in the ContactDo class how will this affect mapping to the table that will display the data?

c) Should all the entities be in their own package or can I put each entity in the package where the Form object and the Page object are located?

d) Does the REST frontend need the server part of a regular Scout application or can the client part communicate with my REST server without passing through the Scout server part?

e) Do I need to create packages for the REST classes?

Thank you very much for your assistance, I look forward to reading your replies. In addition, if anyone can show me a complete working example, it will be greatly appreciated.

Cheers,

JD
Re: REST frontend questions [message #1838891 is a reply to message #1838890] Mon, 08 March 2021 11:15 Go to previous messageGo to next message
Paolo Bazzi is currently offline Paolo BazziFriend
Messages: 33
Registered: January 2017
Location: Switzerland
Member
Hi JD,

J D wrote on Mon, 08 March 2021 09:42
Hi there everyone,

I've been working on the project building menus, pages and forms and so far so good. I am very pleased with the default functionality in Eclipse Scout 10 tables. They are really good.

The next steps for me are what Andre advised in his response here https://www.eclipse.org/forums/index.php?t=msg&th=1106874&goto=1837778&#msg_1837778

Following that threw up the following questions:

a) I want to start creating the various entities for the application. I have been reading Chapter 16 Data Objects in the Scout Technical Guide. I created an entity for contacts but I'm not sure if what I did is correct:

public class ContactDo extends DoEntity {

  public DoValue<String> contactId() {
    return doValue("contactid");
  }

  public DoValue<String> firstName() {
    return doValue("firstname");
  }

...


Your data object code looks correct, just the method names and string literals should be identical, see comment below:

J D wrote on Mon, 08 March 2021 09:42

b) My server sends JSON documents with key values in French so for instance, instead of "firstname", it will send "prenom". Should I have return doValue("prenom") instead of return doValue("firstname") and so on in the ContactDo class how will this affect mapping to the table that will display the data?

The name of the attribute method (here for instance firstname()) must be identical to the string literal used within the method (here "firstname"). If the method should have another name than the attribute name within the JSON document, you can use the AttributeName annotation. See the example here: https://eclipsescout.github.io/10.0/technical-guide.html#rename-an-attribute-of-a-data-object-in-a-subclass

Or with your data object:

  @AttributeName("prenom")
  public DoValue<String> firstName() {
    return doValue("prenom");
  }


J D wrote on Mon, 08 March 2021 09:42

c) Should all the entities be in their own package or can I put each entity in the package where the Form object and the Page object are located?


It depends whether you want to use the data object classes only in your frontend code or also in your backend code where you load and store the data.
If you use the data objects just for de client/UI layer, you can put them in the same packges as your forms and pages. If you use the data objects also in your REST backend (if it is also Scout-based) then you should put the data objects in a module shared between frontend and backend.

J D wrote on Mon, 08 March 2021 09:42

d) Does the REST frontend need the server part of a regular Scout application or can the client part communicate with my REST server without passing through the Scout server part?


No it does not need to pass through the Scout server part. The Scout client is able to invoke REST endpoints, it just needs a few Scout modules providing the functionality for REST and data objects but not the complete Scout server modules dependencies.

I think this dependencies should enable the REST (and therefore Jackson/Jersey) dependency in order to be able to invoke a REST endpoint from your client:
    <!-- JAX-RS Jersey Client -->
   <dependency>
      <groupId>org.glassfish.jersey.connectors</groupId>
      <artifactId>jersey-apache-connector</artifactId>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.inject</groupId>
      <artifactId>jersey-hk2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.media</groupId>
      <artifactId>jersey-media-json-jackson</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.scout.rt</groupId>
      <artifactId>org.eclipse.scout.rt.rest.jersey.client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.scout.rt</groupId>
      <artifactId>org.eclipse.scout.rt.rest.jackson</artifactId>
    </dependency>


J D wrote on Mon, 08 March 2021 09:42

e) Do I need to create packages for the REST classes?

That's up to you but not strictly necessary.

Cheers,
Paolo


Eclipse Scout Homepage | Documentation | GitHub
Re: REST frontend questions [message #1838910 is a reply to message #1838891] Tue, 09 March 2021 07:01 Go to previous message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
@Paolo
Thanks a lot for your suggestions. Much appreciated.

Cheers,

JD
Previous Topic:Eclipse Scout Hello World tutorial issue
Next Topic:Sticky columns in tablea
Goto Forum:
  


Current Time: Fri Dec 13 03:02:48 GMT 2024

Powered by FUDForum. Page generated in 0.03358 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top