Extjs form - findField is not defined - forms

I am selecting a form in Extjs as the following:
var form = Ext.getCmp(mainTabsId).getActiveTab().down().getForm("add-form");
//I am getting here the correct id.
console.log(form.id);
But when I am trying to find a field inside like that I am getting the following error:
form.findField("Address").getValue();
Uncaught TypeError: Object [object Object] has no method 'findField'
this is the console.log of form http://pastebin.com/EuVizyCZ

findField is a method of Ext.form.Basic, not Ext.form.Panel... So you have to do:
form.getForm() // get the BasicForm ref
.findField('Address')
.getValue();
Update
By guessing from your code, I would try:
// supposing add-form is the id or itemId of a FormPanel
Ext.getCmp(mainTabsId).getActiveTab().down('#add-form').getForm()

Related

Getting [object Object] instead of value in protractor getText()

I am trying expect the value like
var foo = element(by.name('salutId'));
expect(foo.getText()).toEqual('MS');
console.log(foo); -- shows like [object Object]
Failed: No element found using locator: By(css selector, *[name="salutId"])
.getText() returns a promise. Promise is on object. Thus what you see is expected
In order to resolve a promise and get the value, you should use either await or .then
While first syntax is recommended, I'll show you an example with the second
foo.getText().then(value => {
console.log(value)
expect(value).toEqual('MS');
)

Symfony Form - Value Object, DataMappers and EventSubscriber

I am having trouble to dynamically modify field in my form using DataMapper and EventSubscriber.
Here is my form:
A select field
A field which will be modified by the select field above.
I am using an EventSubscriber to dynamically modify my form using AJAX.
And a DataMapper to map my Value Object to the form and vice-versa.
So when i do that:
$moneyForm = $this->createForm(MoneyType::class);
Everything is working. But when i pass my Value Object as data class:
$money = new Money(199, 'USD');
$moneyForm = $this->createForm(MoneyType::class, $money);
I got an error here:
public function mapDataToForms($viewData, $forms)
{
$forms = iterator_to_array($forms);
$forms['money']->setData($viewData ? $viewData->money() : 0);
$forms['currency']->setData($viewData ? $viewData->currency() : 'USD');
}
This error says that: Notice: Undefined index:.
It seems like the form has been replaced by a new one and i don't understand it.
I don't know why when i use a data mapper alone, or event subscriber alone everything is working.
But when i try to mix, both of them i got this error.
Does anyone have a clue of what's going on here?
Thank you

Error when trying to get single item from element.all in Protractor

I have the following test code (a simplified example):
e = element(by.id('element-id'));
it('description', function(){
e.all(by.tagName('my-directive')).then(function(items){
expect(items.count()).toEqual(3); //error
expect(items.length).toEqual(3); //ok
expect(items.get(0).getAttribute('my-attr')).toEqual('1'); //error
});
});
This is the HTML:
<div id="element-id">
<my-directive my-attr="1"></my-directive>
<my-directive my-attr="0"></my-directive>
<my-directive my-attr="0"></my-directive>
</div>
When I run this test I get the following error:
TypeError: undefined is not a function
I stripped it down and found out that the error is from the get() function and the count() function. I have read about the functions in the Protractor API and used them the same way as the example on the site, so I don't understand why it does not work for me.
Does anyone know what I'm doing wrong?
I have also tried this (included 'element'):
e.element.all(by.tagName('my-directive')).then(function(items){...})
But that gave an error event without the get() function.
items in this case is just an ordinary array. You get
TypeError: undefined is not a function
because there isn't any function on the Array.prototype called count.
count() and get() can only be called on ElementFinderArrays, which is a Protractor specific object: http://angular.github.io/protractor/#/api?view=ElementArrayFinder
If you want to get the length and one of the elements' attribute, this will work:
e.all(by.tagName('my-directive')).then(function(items){
expect(items.length).toEqual(3);
expect(items[0].getAttribute('my-attr')).toEqual('1');
});
or like this:
expect(e.all(by.tagName('my-directive')).count()).toEqual(3);
expect(e.all(by.tagName('my-directive')).get(0).getAttribute('my-attr')).toEqual(1);

AttributeError: 'Bottle' object has no attribute 'template'

Example One
Consider the following:
import bottle
import pymongo
application = bottle.Bottle()
#application.route('/')
def index():
cursor = [ mongodb query here ]
return application.template('page1',{'dbresult':cursor['content']})
Assume that the MongoDB query is correct, and the application is calling the content value of cursor correctly and passing it to the template which is formatted correctly.
The errors I am getting in the logs are to do with being able to use the template() method eg:
AttributeError: 'Bottle' object has no attribute 'template'
Example Two
If I change the corresponding assignment and call to:
application = bottle
application.template
The error is:
TypeError: 'module' object is not callable
Example Three
If I change the corresponding assignment and call to:
application = bottle
#application.route('/')
#application.view('page1.tpl')
return {'dbresult':cursor['content']}
The error is:
TypeError: 'module' object is not callable
Question
What is the correct call to the template() method to use to get Example One working?
To get "Example One" working:
return bottle.template('page1',{'dbresult':cursor['content']})
template() is in the bottle module; just reference it as bottle.template(...).
bottle.template() isn't a method of the bottle.Bottle() application object. It's a function in the bottle module.

Populate Tabular form field value with change of another field

There is a Tabular form with description, previous_value, unit_price fields in my Oracle Apex app.
I need to populate value of previous_value field with data on description field. I have a query to get value for previous_value field from database. i need to add onChange event to description field. with the changes in description field, value for previous_value field should be populate using my query.
how could i do this ?
You can bind the change event to the field in several ways. Target through the td headers,
or edit the column, and in the "Element attributes" field you could add a class (eg "fireAjax").
You can then bind to the event with either javascript code, or do this via a dynamic action.
You can do an ajax call in either of these 2 forms: through htmldb_Get or with jquery.post:
$('td[headers="ENAME"] input').change(function(){
var ajaxRequest = new htmldb_Get( null , $v('pFlowId') , 'APPLICATION_PROCESS=get_job' , $v('pFlowStepId'));
ajaxRequest.addParam('x01', $(this).val());
ajaxResult = ajaxRequest.get();
$(this).closest("tr").find("td[headers='JOB'] input").val(ajaxResult);
});
OR
$('td[headers="ENAME"] input').change(function(){
var that = this;
$.post('wwv_flow.show',
{"p_request" : "APPLICATION_PROCESS=get_job",
"p_flow_id" : $v('pFlowId'),
"p_flow_step_id" : $v('pFlowStepId'),
"p_instance" : $v('pInstance'),
"x01" : $(this).val()
},
function(data){
var eJob = $(that).closest("tr").find("td[headers='JOB'] input");
eJob.val(data);
},
"text"
);
});
With this application process, defined on the page with execution point "AJAX Callback":
Name: get_job
DECLARE
l_job emp.job%TYPE;
BEGIN
SELECT job
INTO l_job
FROM emp
WHERE ename = apex_application.g_x01;
htp.p(l_job);
EXCEPTION WHEN no_data_found THEN
htp.p('');
END;
Remember, handling errors and return in this process is up to you! Make sure you catch common errors such as no_data_found and/or too_many_rows. If they occur and are not trapped, chances are big you will encounter javascript errors because your javascript callback code can not handle the error (which in apex will be a full page html with the error message in it).
Also, as you can see i'm using the x01 variable, which is one of the 10 global temporary variables in apex. This way it is not required to use a page item and submit the value to session state for it.
If you want to put this code in a dynamic action you can. Pick "Change" as event and jQuery selector if you go for a dynamic action, and as true action pick execute javascript code. You can then put the function code in there. With the exception that $(this)will need to be $(this.triggeringElement)