This has been driving me crazy for hours and its probably very obvious to someone ...
Can anyone see why this is printing out even though its reporting as being false?
<g:if test="${className == 'SRep'}">
${className == 'SRep'}
</g:if>
If classname==SRep then its correct. However if classname <> SRep it still prints out false? I don't understand how this can be.
If I use ?showSource=true, the if statement looks like this:
if(true && ("false")) {
printHtmlPart(29)
}
else {
printHtmlPart(30)
}
Anyone see anything obvious?
Thanks
John
your code looks fine but im not sure what 'className' is, perhaps it's not being returned or returning wrong type etc:
i would display the output in the GSP of className just to see what it is
e.g. add this anywhere in your GSP:
${className} //displays the value
you may also want to check the object type, in your case i think it should be string
so check what you have:
${className?.class} //displays the type of object
Related
I know that this may sound a bit silly, but I am facing the situation as stated in the title. When I open the Xcode playground and test out the value, it is working as expected, there is nothing wrong. However, when part of my iOS code run it, the value becomes larger by one.
To illustrate clearer, part of the code looks something like the following (numberOfLists is an array):
if numberOfLists.count == 0 {
listIndex = Int16(0)
} else {
listIndex = Int16(numberOfLists.count)
}
print(listIndex)
When I print out the value of listIndex, when I expect it to be 0, it prints 1; when I expect it to be a certain positive integer, let's say, a, the printed value is a+1. It seems like the "+1" is consistent.
Has anyone encountered this situation before?
in the below code I would like to change the final IF NOT statement to say either HEADING or SPACE. I have tried to play around with it (I did not write this code) without success. Sorry am not an expert not sure what code it is in! Any ideas? Thanks
if [POS('HEADING',[DF.Items."CODE"])] then MemoLRV.visible:=false;
if [POS('SPACE',[DF.Items."CODE"])] then MemoLRV.visible:=false;
if [POS('HEADING',[DF.Items."CODE"])] then MemonameV.font.Color:=clmaroon;
if not [POS('HEADING',[DF.Items."CODE"])] then MemonameV.font.Color:=clblack;
if not [POS('HEADING',[DF.Items."CODE"])] then MemoLRV.visible:=true;
In FastReport function IF :
IF(Expression, Value1, Value2)
Returns Value1 if expression Expression is True, otherwise returns Value2. Return value can be not only string.
I want to do a check on a ListBox if it is empty, like:
if {Listbox.Items is empty} then
begin
Listbox.Items.Add('Item');
end else
begin
//do somthing else
end;
The part of the check if Listbox.Items or if Listbox are/is empty is a little hard for me. I tried to figure out a way how to do it, but I failed as I am still a beginner with Delphi. How can I implement that in Delphi XE5?
if listbox.items.count = 0 then
// it's empty
In Access VBA there is no ".items.count" property on a Listbox
I tried Me.ListBox.ListCount and .ListIndex to see if the List was empty.
ListCount was always 1 and ListIndex always -1 whether the list was empty or not (in my case).
To overcome that I used:
If Me.ListBox.ItemData(0) = "" then
Do Something
End If
This worked for me - hope this helps someone
I would reverse your if statement.
Personally I like the most code in the true part of my statement and the shorter code in the false part. For some reason it makes more sense to me.
So the code would look like:
If Listbox.items.count > 0
begin
//Do something else
end
else
Listbox.items.add('item');
Also if your true, or false, part only contains 1 line of code you don't need a begin..end. It's not wrong to have them but in my opinion it makes code easier to read if they aren't there ;)
I have another probably basic problem. happy if u can help.
there is a request parameter 'action'. if I write :
<label><s:property value="%{#parameters.action}"/></label>
the value appears (it is 1)
So itry to test now :
<s:if test="%{#parameters.action == '1'}">YES 1</s:if><s:else>NOT 1</s:else>
NOT 1 appears.
I have tries all the syntaxes I found on the net for the test. Nothing changes, NOT 1 still displays
Thank you
This is because:
the value of %{#parameters.action} is an array, not a single value, and
the value will be type-converted to a number (not sure why; need to look in to that)
The correct expression would be:
<s:if test="%{#parameters.action[0] == 1}">YES 1</s:if><s:else>NOT 1</s:else>
The correct expression would be:
<s:if test="#parameters.action[0] == 1">YES 1</s:if><s:else>NOT 1</s:else>
The request parameters is a map of [Strinf, String[]], So you have to access it like above
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");