pippo icon indicating copy to clipboard operation
pippo copied to clipboard

Improve body collection support

Open mhagnumdw opened this issue 5 years ago • 7 comments

Any ongoing solutions or ideas for this? https://github.com/pippo-java/pippo/blob/cb5ccb453bffcc3cf386adc660674812d10b9726/pippo-controller-parent/pippo-controller/src/main/java/ro/pippo/controller/extractor/BodyExtractor.java#L43

This works as expected.

public void updateChanges(@Body ChangeFormDTO[] changesArray) {

But that does not

public void updateChanges(@Body List<ChangeFormDTO> changes) {

mhagnumdw avatar Oct 12 '19 16:10 mhagnumdw

But that does not

public void updateChanges(@Body List<ChangeFormDTO> changes) {

And what is the message?

Did you see any possible improvement?

decebals avatar Oct 12 '19 17:10 decebals

Hi, @decebals !

And what is the message?

The conversion is done but not with the expected result. See the image below.

image

Did you see any possible improvement?

Not until now. I took a quick look at it. I saw that Gson solves this using the TypeToken class: https://stackoverflow.com/questions/5554217/google-gson-deserialize-listclass-object-generic-type But I didn't stop to see what should be the change in Pippo to work with Gson and other engines.


I believe the classes in Pippo to start looking at this are:

mhagnumdw avatar Oct 12 '19 17:10 mhagnumdw

@mhagnumdw What is the status of this issue? I try to switch from plain routes to controllers and I have this scenario (very common):

  • UI with HTML form (entity editor)
  • controller with method save(@Body ClientDto client)

Is it possible to use something like this in controller? Is it possible to extract the client object from different encoding type of a form?

decebals avatar Aug 03 '20 20:08 decebals

Hi @decebals !

I took a good look at this. It is not such a simple change.

Each framework has its own way of working with generic types. Gson uses TypeToken, Fastjson uses TypeReference, Jackson TypeReference, and so on.

We have to figure out the type of the parameter defined in the controller method to reach the ContentTypeEngine. Currently only the class (raw type) arrives, but if it is generic the parameters do not arrive in the engine. (Calm down, I have a draft :))

I created a local draft with a possible solution. I have already tested using Gson, but in theory it should work for the other engines. I want to go further on this after feedback.

It is easier to see what I said here by looking at the code. Can I submit a big draft PR?

mhagnumdw avatar Aug 05 '20 15:08 mhagnumdw

It is easier to see what I said here by looking at the code. Can I submit a big draft PR?

Sure. Why not :).

Also, I am very very curious to see other applications (except for the ones I wrote) that are using Pippo. Now, I am trying to switch from plain routes and to controllers. I love to see how some aspects as security, ajax, templating are used.

decebals avatar Aug 05 '20 16:08 decebals

@decebals , draft PR https://github.com/pippo-java/pippo/pull/564

I await your feedback! So that we can solve this together!

Pippo, onward and upward! 🚀🚀🚀 (I don't know if this is right in English 😄)

Also, I am very very curious to see other applications (except for the ones I wrote) that are using Pippo. Now, I am trying to switch from plain routes and to controllers. I love to see how some aspects as security, ajax, templating are used.

  • Since my beginning with Pippo, I use controllers
  • I created an authentication / authorization scheme from the beginning as well (nor did pippo-pac4j exist, which I never used), I even talked a little about this comment a long time ago (and something may have already changed)
  • I implemented my CorsHandler class (but Pippo already has one of the same name that I also implemented 😃 )
  • I use Freemarker for templates, but my application migrated the front to Angular and the template part will probably only be used for emails
  • I use Jetty, Hibernate, WebSockets, Jasper Reports, Bean Info Generator, EhCache, Google Guice, Guice Persist, H2 database, Integration with Jenkins, SVN, Git, OpenShift, Maven, ... and more stuff!
  • Anything else?

mhagnumdw avatar Aug 05 '20 22:08 mhagnumdw

@mhagnumdw Can you send me an email (see my gmail address in my GitHub's profile). I want to talk more about how you use PIppo but I don't want to hijack this thread. Thanks!

decebals avatar Aug 06 '20 11:08 decebals