Skip to content

Improve body collection support #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mhagnumdw opened this issue Oct 12, 2019 · 7 comments
Open

Improve body collection support #524

mhagnumdw opened this issue Oct 12, 2019 · 7 comments

Comments

@mhagnumdw
Copy link
Member

Any ongoing solutions or ideas for this?

This works as expected.

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

But that does not

public void updateChanges(@Body List<ChangeFormDTO> changes) {
@decebals
Copy link
Member

But that does not

public void updateChanges(@Body List changes) {

And what is the message?

Did you see any possible improvement?

@mhagnumdw
Copy link
Member Author

mhagnumdw commented Oct 12, 2019

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:

@decebals
Copy link
Member

decebals commented Aug 3, 2020

@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?

@mhagnumdw
Copy link
Member Author

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?

@decebals
Copy link
Member

decebals commented Aug 5, 2020

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.

@mhagnumdw
Copy link
Member Author

@decebals , draft PR #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?

@decebals
Copy link
Member

decebals commented Aug 6, 2020

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants