Polymer reset parameters format not working - forms

I am new to Polymer 2.0. I need to update a field called Print Name to set the values I put in First Name + Last Name. Currently I get a version of it that is not working as I get bad request. 'System.FormatException: Input string was not in a correct format.'
_updateField(e) {
e.preventDefault();
this.set('_contract.signeeContact.printName', [this._contract.signeeContact.firstName, this._contract.signeeContact.lastName]);
// printName: ["firstName", "LastName"] // this is not correct it should be
// printName: ["firstName LastName"] // correct request should look like this
}
the format is not correct. Can someone give me a hand with this?
Thank you in advance.

Related

Uri.Parse() is adding random characters inside the uri

When I try to create a Uri object using Uri.parse, I get %0D%0A added after `_countryCode` value
This is what gets logged
http://api.geonames.org/countryInfo?country=US%0D%0A&username=medcollapp
value of _countryCode is a string like US or IN.
_countryCode is not empty I made sure of it.
I have no idea how to fix this any help would be appreciated.

Sending an array as a query parameter to a rest WS (nullpointerException)

I need to call a rest web service in playframework 2 and I need to send a query parameter which is an array. In regular html I would send it like:
GET http://host.com?a=1&a=2&a=3
But when I do it when I try to do it with the playframework 2 WS api I do the next:
Map<String,String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("a",new String[]{"value1","value2"});
WS.WSRequestHolder holder = WS.url("http://host.com");
Set<String> keys = paramMap.keySet();
for (int i = 0; i < paramMap.get(key).length; i++)
{
holder.setQueryParameter(key, paramMap.get(key)[i]);
}
And the first time that setQueryParamater() arrives, everything goes perfect but the second time I get a NullPointerException and paramMap.get(key)[i] is not null. Is this possible? is there any workaround?
Thanks in advance!
In regular html you need to dsend it like:
GET http://host.com?a=1&a=2&a=3
Using ampershand(&) to separate parameters in query string instead of comma(,)
Edit: Sorry forgot to type: Like ur trying to do within the loop you should not have fields with same name. You should change it as:
http://host.com?a1=value1&a2=value2
I don't know if this causes NullPointerException you face. But even if does not i suggest you change ur implementation to keep one value per field (key, value)
Ok, it seems to be a bug in play-framework, but solved in 2.1 version.
https://play.lighthouseapp.com/projects/82401/tickets/360-bug-in-wsjava-setqueryparameter-leads-to-npe-when-adding-a-query-parameter-twice

Using changestamp in GoogleDocs (null changestamp)

I am trying to find the max changestamp so I can start using it. I tried the following:
URL url = "https://docs.google.com/feeds/default/private/changes?v=3"
ChangelogFeed foo = service.getFeed(url, ChangelogFeed.class);
LargestChangestamp stamp = foo.getLargestChangestamp();
stamp is always null.
Is this the way to get the largest changestamp, or do I need to set it first in order to use it?
The largest changestamp is also available in the user metadata feed. See the "docs:largestChangestamp" element within the response protocol tab here,
I'm not sure the java api exposes the largestChangestamp property directly yet - last time I checked it was hidden in the xmlBlob property, and I had to do an xml parse to grab it out.
This seems to be a bug in the API. I got the changestamps by getting the ChangelogEntrys from the ChangelogFeed:
List<ChangelogEntry> entries = foo.getEntries();
for (ChangelogEntry entry: entries) {
String blob = entry.getXmlBlob().getBlob();
System.out.println("Blob: " + blob);
}
The changestamp for an entry is contained in its blob.

zfdatagrid date format

I am using ZF 1.11, PHP 5.3, Windows and the most recent version of zfdatagrid.
I use
$grid->updateColumn('birthday', array('format'=> array('date',array('date_format' => 'dd-MM-yyyy'))));
to display an attribute "birthday" as dd-MM-yyyy. When I click on the Edit button (CRUD enabled), the value of this attribute is being displayed as 'yyyy-MM-dd'. When the user clicks the save button, he gets an error message (Please, enter date as dd-MM-yyyy).
How can I tell the $form to display the value as dd-MM-yyyy instead of yyyy-MM-dd?
looking at the docks I think your code maybe slighty incorrect:
$grid->updateColumn('birthday', array('format'=> array('date',array('date_format' => 'dd-MM-yyyy'))));
Maybe:
$grid->updateColumn('birthday', array('format'=> 'date',array('date_format' => 'dd-MM-yyyy')));
looks like you had an extra array() at date.
reference:
Date ZFDatagrid will for a key in Zend_Registry with the name
Zend_Locale and use it. You can also pass as argument a instance of
Zend_Locale or an array with the following options
locale
date_format
type
$grid->updateColumn('field',array('format'=>'date'));
thanks, but that doesn't solve the problem. Actually, what I did now is to add an event listener for the crud.form_built event. The method called in this event simply creates a new Zend_Validate_Date object and assigns this validator to the corresponding zfdatagrid element.
This is a hack indeed, but it works. Actually, zfdatagrid doesn't really work with PostgreSQL and the manual is incorrent in many places.
!Warning maybe bad English!
for i.e. "localized" values in forms i do something like this..
after passing form to the grid $grid->setForm($myform);
but before the call of $grid->deploy();
i get the form element and set the value manually like the following
$Form=$grid->getForm(1);
$dateVal = $Form->getElement('birthday')->getValue();
if(Zend_Date::isDate($dateVal,'yyyy-MM-dd', 'en'))
$dateObject = new Zend_Date($dateVal);
$Form->getElement('birthday')
->setValue($dateObject->toString('dd.MM.yyyy'))
->setValidators(array(new Zend_Validate_Date('dd.MM.yyyy')))
;
then register a zfdatagrid event trigger "crud.before_update"
$grid->listenEvent('crud.before_update', array($this, '_updateCallback')
that calls a function from this controller _updateCallback() with something custom like this
public function _updateCallback(Bvb_Grid_Event $e)
{
$n = $e->getParam('newValues');
list($d,$m,$y) = explode('.', $n['birthday']);
$sqldate = $y.'-'.$m.'-'.$d;
$n['birthday'] = $sqldate;
$e->setParam('newValues', $n);
}
or just use Zend Date like before to refactor date to ensure that
the datevalue we want to save, is in a sql valid US date format..
hope this will help..
z.

Extjs Form Action Submit - Custom override?

Looking at the source code of Action.Submit, I'm trying to figure out where ext is appending the form's fields to the parameters.
Instead of sending each field as a separate parameter, I want to send something like:
formObj:{field1:value, field2:value}
Currently, each of those values are simply added to the parameter list along with any custom/baseParams.
Where are these formfields being added so that I can change this behaviour?
Thanks.
I'm not sure what your override needs to look like, but you'll probably want to look at Ext.Ajax.request() (in Core / Connection.js). When posting a form, the fields get serialized there, in this code block:
if(form = Ext.getDom(o.form)){
url = url || form.action;
serForm = Ext.lib.Ajax.serializeForm(form);
p = p ? (p + '&' + serForm) : serForm;
}
If you really want to track the process of creating parameter list, you can refer to Ext.form.Action.getParams.
You should also consider Ext.form.BasicForm.getValues as it returns exactly the result you want, the only problem is that you'll need to send it manually, e.g. using Ext.Ajax.request.