Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:06:04+00:00 2026-06-03T05:06:04+00:00

I am building a webservice with playframework 2 and extjs4. Until today I have

  • 0

I am building a webservice with playframework 2 and extjs4. Until today I have managed to overcome any obstacle. But this is something I can’t deal with alone. I followed tutorial, but it didn’t help me. Well, at first it did. I know it worked, I was able to add some values to the database (mongodb). I doubt if it is important, but:

  • everything worked fine, I added some test data into db
  • I wrote some other methods in Java
  • I used db.Category.remove() on my mongo collection
  • server is unable to receive any values from form now

I have a Ext.FormPanel with 2 fields:

items: [
    { 
        id: 'categoryName',
        fieldLabel: 'Category name', 
        name: 'categoryName', 
        allowBlank: false 
    },{
        xtype: 'textarea',
        id: 'categoryDescription',
        fieldLabel: 'Description',
        name: 'categoryDescription',
        allowBlank: true
    }
]

Corresponding Model class looks like that:

@MongoCollection(name = "Category")
public class CategoryModel{
    private String categoryName;
    private String categoryDescription;

    @JsonProperty("categoryName")
    public String getName() {
        return categoryName;
    }

    @JsonProperty("categoryName")
    public void setName(String name) {
        this.categoryName = name;
    }

    @JsonProperty("categoryDescription")
    public String getDescription() {
        return categoryDescription;
    }

    @JsonProperty("categoryDescription")
    public void setDescription(String description) {
        this.categoryDescription = description;
    }

    public String toString(){
        ObjectMapper mapper = new ObjectMapper();
        String json = null;
        try {
            json = mapper.writeValueAsString(this);
        } catch (JsonGenerationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JsonMappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return json;
    }
}

And finally, here’s where I want to receive values:

Form<CategoryModel> categoryForm = form(CategoryModel.class);
System.out.println(categoryForm);

Output from Play console:

Form(of=class kunto.models.CategoryModel, data={}, value=None, errors={})

Firebug shows that POST values are being sent correctly:

categoryDescription test
categoryName    test

And I have POST request type in conf/routes defined on the server side for this particular request.

I have 2 questions:

  • what to do to fix it?
  • more importantly, why did it happen?

EDIT
As @adis suggested:

Form<CategoryModel> categoryForm = form(CategoryModel.class).bindFromRequest();
System.out.println(categoryForm);
System.out.println(categoryForm.data());

outputs:

Form(of=class kunto.models.CategoryModel, data={categoryName=test, categoryDescription=test}, value=Some({"categoryName":null,"categoryDescription":null}), errors={})
{categoryName=test, categoryDescription=test}

I also checked

CategoryModel categoryModel = form(CategoryModel.class).bindFromRequest().get();
System.out.println(categoryModel);

it outputs: {"categoryName":null,"categoryDescription":null}

Anyone can explain this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:06:05+00:00Added an answer on June 3, 2026 at 5:06 am

    As commented you have to bind the request to a model by:

     Form<CategoryModel> categoryForm = form(CategoryModel.class).bindFromRequest();
    

    This will allow you do also checks on the properties in you model if you have defined them, like: @Contraints.Required.

    After the binding, you get the form object and get the model instance:

    CategoryModel newCatModel = categoryForm.get();
    

    This should give you an instance of your model populated with the data from your post reqeust. Usually this method looks like:

    Form<Task> taskForm = form(Task.class).bindFromRequest();
    
    if (taskForm.hasErrors()) {  // check for constraints
        Logger.info("Error:" + taskForm);
        return badRequest(views.html.task.create.render(taskForm));
    }
    // here get the model instance
    Task newTask = taskForm.get();
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im building a REST webservice and have of course done some research but are
I have to make a call to a webservice but building the xml manually.
hoping someone can hel pon this one... I am building a webservice to be
I have an iPhone app accessing an ASP.NET Webservice for data. Since I'm building
I'm building an app that can upload users' photos to a webservice, and with
I have webservice that can return data in multiple formats. For example json and
Hopefully someone out there can help me with this.....I'm building an MVC3 project and
I get some data from a WebService, which looks like this Building Address ->
I'm building a small webservice and the client is an android client. I must
i'm building a mobile app talking to my symfony2 app via webservices I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.