MultiSelectionHelper not working as expected - x++

I'm trying to perform an operation on multiple lines on my form. I have tried to use multiselectionhelper, and it seems as it would work, but for some reason, it's not. My operation is still looking at the last line I have selected instead of all the selected lines.
myTable myTableTmp;
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();
selectionHelper.parmDatasource(myTable_ds);
myTableTmp = selectionHelper.getFirst();
while (myTableTmp )
{
//perform operation
myTableTmp = selectionHelper.getNext();
}
This looks like it would work, but still not working as expected.
Any help would be greatly appreciated. Thanks!

I have finally figured it out. I'm not sure how I missed it. The answer was really simple. I had this:
myTable myTableTmp;
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();
selectionHelper.parmDatasource(myTable_ds);
myTableTmp = selectionHelper.getFirst();
while (myTableTmp )
{
localTable.methodCall();
myTableTmp = selectionHelper.getNext();
}
I should have used myTableTmp.methodCall() instead of the localtable.methodCall()
Thanks for anyone that tried to help!

Related

Grails 3 Entity not saved when properties set in EntityClass

I occure a problem which I do not understand. Following code does not work:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setLifecycleStatusToArchived();
accountingEntity.save(flush:true);
Where the method setLivecylceStatusToArchived looks like:
void setLifecycleStatusToArchived() {
this.lifecycleStatus = AccountingEntity.LIFECYCLE_ARCHIVED; //predefined static variable
this.considerForRankingJob = false;
this.dateArchived = new Date();
}
Problem is, that the entity is not updated.
No validation erros when I use accountingEntity.validate() in advance.
However, this code works:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setDateArchived(new Date());
accountingEntity.setConsiderForRankingJob(false);
accountingEntity.setLifecycleStatus(AccountingEntity.LIFECYCLE_ARCHIVED);
accountingEntity.save(flush:true);
The code did not work any more after update from Grails 3.2.9 to 3.3.0.RC1 (Gorm 6.1.5) unless I followed all the steps in the guide (http://docs.grails.org/3.3.x/guide/upgrading.html) and the rest of the code is working properly (also database accesses etc.)
Has anybody an idea? What the problem could be?
Thanks in advance and best regards!
The short answer is dirty checking. When you are setting properties inside the instance method Grails doesn't know they are dirty.
See the following github issue for how to resolve the problem:
https://github.com/grails/grails-data-mapping/issues/961
you have 2 options:
call markDirty every time you change an internal field. This will be
better for performance or as per
http://gorm.grails.org/latest/hibernate/manual/index.html#upgradeNotes
use
hibernateDirtyChecking: true

Error loading Partial View script (file: ~/Views/MacroPartials/ezSearch.cshtml)

I am having some issue with ezSearch (Umbraco) and it is very similar to this one
http://our.umbraco.org/projects/website-utilities/ezsearch/bugs-feedback-suggestions/48460-Search-error-when-searching-for-test-keyword?p=0#comment176864
Here is the screenshot of error
http://our.umbraco.org/media/upload/e08b702e-b738-42a4-81d8-382a4400b96a/error.jpg
Can anyone hep me with this please?
Thank you,
Adi
I'm using ezSearch, and from reading the ezSearch.cshtml this looks like a bug if the query passed to the macro is " ". That is to say, if the search is empty, it works ok, but if the search is an actual quoted space then the line in the cshtml: (line 60 in my version)
// Check the search term isn't empty
if(!string.IsNullOrWhiteSpace(model.SearchTerm))
{
// Tokenize the search term
model.SearchTerms = Tokenize(model.SearchTerm);
...
etc.
...
}
ends up with a bad set of tokens in model.SearchTerms.
it's a bit of a hack, but i think putting this before that if statement will help.
model.SearchTerm = model.SearchTerm.Replace("\"","").Replace(" ","").Replace("'","");
..hope that helps.
'ingie.

How do I shorten a one line if statement in ruby that only executes if field is not empty

I have the following if statement that fills a field with the result of a function, if the function doesn't return empty.
I think i've seen examples before where the empty check and the function can be combined in the ifwithout me having to repeat the whole function again in the condition.
I'm looking for newb DRY advice please!
icons = page.search("theicons").to_s if !page.search("theicons").to_s.empty?
is something wrong with
theicons = page.search("theicons").to_s
icons = theicons unless theicons.empty?
If you're using Rails you could shorten it to this:
icons = page.search("theicons").to_s.presence || icons
You can use logical operators:
icons = (page.search('theicons') || default_value).to_s
Try this out:
icons = page.search("theicons").to_s.present? && page.search("theicons").to_s
Note: present? is a rails helper.
icons = page.search("theicons") unless page.search("theicons").present?
or
icons ||= page.search("theicons")

Lua arguments passed to function in table are nil

I'm trying to get a handle on how OOP is done in Lua, and I thought I had a simple way to do it but it isn't working and I'm just not seeing the reason. Here's what I'm trying:
Person = { };
function Person:newPerson(inName)
print(inName);
p = { };
p.myName = inName;
function p:sayHello()
print ("Hello, my name is " .. self.myName);
end
return p;
end
Frank = Person.newPerson("Frank");
Frank:sayHello();
FYI, I'm working with the Corona SDK, although I am assuming that doesn't make a difference (except that's where print() comes from I believe). In any case, the part that's killing me is that inName is nil as reported by print(inName)... therefore, myName is obviously set to nil so calls to sayHello() fail (although they work fine if I hardcode a value for myName, which leads me to think the basic structure I'm trying is sound, but I've got to be missing something simple). It looks, as far as I can tell, like the value of inName is not being set when newPerson() is called, but I can't for the life of me figure out why; I don't see why it's not just like any other function call.
Any help would be appreciated. Thanks!
Remember that this:
function Person:newPerson(inName)
Is equivalent to this:
function Person.newPerson(self, inName)
Therefore, when you do this:
Person.newPerson("Frank");
You are passing one parameter to a function that expects two. You probably don't want newPerson to be created with :.
Try
Frank = Person:newPerson("Frank");

Symfony propel criterion inside for loop

$record_values = new Criteria();
$record_values->add(TblfieldsPeer::CUSTOMER_ID, $company_qu_id);
$record_values->add(TblfieldsPeer::RECORD_TYPE_ID, $query_rtype);
for($fieldid_arrayCount=0;$fieldid_arrayCount<count($fieldIds);$fieldid_arrayCount++)
{
$currentFieldId = $fieldIds[$fieldid_arrayCount];
if(isset($query_values[$fieldid_arrayCount]))
{
$criterion1 = $record_values->getNewCriterion(TblfieldsPeer::FIELDS_ID, $currentFieldId);
$criterion1->addAnd($record_values->getNewCriterion(TblfieldsPeer::FIELD_VALUES, $query_values[$fieldid_arrayCount]));
$record_values->add($criterion1);
}
}
$record_values_results = TblfieldsPeer::doSelect($record_values, $con1);
But only last criterion is added. I check the databases in debug toolbar only the last criterion is there. What could be the problem.
Please help me....
I'm not a propel expert but maybe you could try to use 2 alternative changes:
to use addAnd statement instead of add one in $record_values->add($criterion1)
to put $record_values->add($criterion1) outside the (of course after) cycle changing $criterion1 in a field outer the cycle and using only the addAnd statement for $criterion1

Resources