Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
bindFromRequest not working with select
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ben  
View profile  
 More options Oct 31 2012, 11:49 pm
From: Ben <ben.su...@rnd.designcom.com.au>
Date: Wed, 31 Oct 2012 20:49:06 -0700 (PDT)
Local: Wed, Oct 31 2012 11:49 pm
Subject: [2.0.2] bindFromRequest not working with select

Hi guys,
So I have an issue with my play/scala atm and was wondering if anyone could
help.
So what I have is a configuration page that is allowing you to set the
network interface adapter, and then you can submit the form and save the
settings.

So i display the list of network interfaces with scala with the following
code:

            <select id="networkInterfaces">
                <option value="">First Available</option>
                @for(interface <- networkInterfaces) {
                    @if(interface.Name ==
configs.last.networkInterfaceName) {
                        <option selected="selected"
value="@interface.Name">@interface.DisplayName</option>
                    } else {
                        <option
value="@interface.Name">@interface.DisplayName</option>
                    }
                }
            </select>
And my form code:
public static Result newConfiguration() {
        Form<SystemConfiguration> filledForm = configForm.bindFromRequest();
        if (!filledForm.hasErrors()) {
              SystemConfiguration.create(filledForm.get(), session("name"));
        }

}

But my problem is if I load the value as selected, it displays as if it is
selected in html and even $('networkInterfaces').val() is correct but if I
do not actually select anything manually then for some reason the value
passed to the filledForm.get() is the @interface.DisplayName instead of
@interface.Name

Have I done something wrong?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Roper  
View profile  
 More options Nov 1 2012, 10:36 pm
From: James Roper <jrop...@gmail.com>
Date: Thu, 1 Nov 2012 19:36:00 -0700 (PDT)
Subject: Re: [2.0.2] bindFromRequest not working with select

First of all, checkout @helper.select, as it can probably help you here, eg:

@helper.select(form("networkInterfaces"), networkInterfaces.map(i =>
(i.Name -> i.DisplayName))

Now to solving your problem:

1) Have you checked what gets rendered?  Is what you are expecting in the
value field?
2) Have you checked what is going over the wire using browser developer
tools (eg, firebug, or the chrome developer console)?

Cheers,

James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[2.0.2] bindFromRequest not working with select" by Paulo JCranky Siqueira
Paulo JCranky Siqueira  
View profile  
 More options Nov 5 2012, 4:25 am
From: "Paulo \"JCranky\" Siqueira" <paulo.sique...@gmail.com>
Date: Mon, 5 Nov 2012 07:25:19 -0200
Local: Mon, Nov 5 2012 4:25 am
Subject: Re: [play-framework] Re: [2.0.2] bindFromRequest not working with select

Just a guess, but I think your select should have a name attribute.  :-)

[]s,

Paulo "JCranky" Siqueira
http://jcranky.com
http://lojinha.paulosiqueira.com.br
Em 02/11/2012 00:36, "James Roper" <jrop...@gmail.com> escreveu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »