Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15th Feb 2007, 05:02
dformica dformica is offline
Registered Developer
 
Join Date: Jan 2007
Posts: 4
Default Posting the actual value in a select list

I have a select list in my form and I need to pass the actual value (1) not (one) just as in an html form:
<option value=”1”>one</value>.
It seems like it only passes the displayed value (one). How can I accomplish this?
I also noted that without the editorType: "comboBox" in the select field it does not pass any value at all.

See code below:

<script>
isc.DynamicForm.create({
method: "get",
action: "index.cfm",
ID: "exampleForm",
width: 250,
position: "relative",
fields: [
{name: "Site",
title: "Site",
editorType: "comboBox",
type: "select",
required: false,
valueMap: {
"1":"one",
"2":"two"
}

},
{name: "submit",
required: true,
title: "Search",
type: "submit"
}
]
});
</script>

Last edited by dformica; 15th Feb 2007 at 05:08..
Reply With Quote
  #2  
Old 15th Feb 2007, 09:45
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

Hello dformica,

First question - are you sure you want to do a normal HTML form submit? Although SmartClient's DynamicForm's retains the ability to do basic HTML submits, the flexible client-server integration facilities have obsoleted that approach for all but a few edge cases.

As far as your example, you need to set canSubmit:true, which causes extra hidden HTML form elements to be created to represent values held by SmartClient's form controls. This was inadequately documented in 5.5.1 (appearing only in the Struts examples in the SDK) but has since been corrected - sorry you ran into it.

Last edited by Isomorphic; 15th Feb 2007 at 10:42..
Reply With Quote
  #3  
Old 15th Feb 2007, 09:58
dformica dformica is offline
Registered Developer
 
Join Date: Jan 2007
Posts: 4
Default

Thank you for your response.
No, I don’t want to do a normal html form. I want the select list and radio buttons to send their values as they do in a HTML form.

I have added -> canSubmit:true
But my list still submits the value “one” instead of “1”.
valueMap: ["1" : “one”]
Reply With Quote
  #4  
Old 15th Feb 2007, 11:04
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

Hello dformica,

If you use a SelectItem and do a submit with canSubmit:true, you'll see the values from the valueMap used.

With a comboBox, where the user can enter values that do not appear in the valueMap, we don't automatically convert the displayed value to the valueMap value on a HTML form submit.

However, I want to recommend again that you take a look at the client-server integration documentation. It's likely that you are persuing an integration strategy that is more difficult than it needs to be.
Reply With Quote
  #5  
Old 16th Feb 2007, 06:46
dformica dformica is offline
Registered Developer
 
Join Date: Jan 2007
Posts: 4
Default

Thank you, that worked.
But now the rest of the fields in the form that are submitted with no value or blank get submitted with the value of ‘undefined’.
Is there way to have the the empty fields get submitted blank?
I have tried defaultValue="" for each field but no luck.
Reply With Quote
  #6  
Old 16th Feb 2007, 12:27
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

You can avoid this by making the blank entry an official part of the valueMap, like so:

Code:
{name: "Site", 
  title: "Site", 
  type: "select",
  defaultValue:"",
  valueMap: {
      "1":"one",
      "2":"two",
      "" : ""
  }
}
I should mention that none of these issues occur with normal SmartClient databinding, only with the legacy pathway you are using (native HTML form submit). If you call exampleForm.getValues() you'll see the logical values relied upon by all other SmartClient subsystems, and they are exactly as you have been expecting to find using your current approach.
Reply With Quote
  #7  
Old 20th Feb 2007, 07:49
dformica dformica is offline
Registered Developer
 
Join Date: Jan 2007
Posts: 4
Default

Is there an example of a form that would post and display the values entered to better understand how to use the getValues() method.

Does DymanicForm post form values as javascript values?
Reply With Quote
  #8  
Old 20th Feb 2007, 11:33
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

You can find a selection of running examples demonstrating client/server communication in your SDK here: http://[host:port]/examples/server_integration/index.html

These demonstrate a number of ways to use the SmartClient RPCManager code to perform communication with the server, from a direct RPC call (passing in arbitrary data, which could be gleaned from a form via a simple 'getValues()' call), to using a DataSource to specify the fields to display in a form (or other component), and using standard flow methods such as "DynamicForm.saveData()" to pass the data to the server.
All running server code is of course included for each of these examples

For more information on the recommended client-server communication approaches, we also suggest you take a look at the documentation here: http://www.smartclient.com/docs/5.5....verIntegration.

Regards
Isomorphic Software
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved