In XPAND template, I have a call where, the call should be done for the method which takes the String and the Object.
i.e. ,
«setData("String",Object)-»
For the above method, the String value I want to pass is the simplified value of below string:
where ,«getAddress(object)» , return dynamic value.
"/begin DATA XETK DEFAULT_RASTERS «getAddress(object)» /end DATA"
If I try to do this in the below way, i get compilation error.
«setData("/begin DATA XETK DEFAULT_RASTERS «getAddress(object)» /end DATA",Object)-»
Can anyone help me, how can I pass this string to the method?
Thanks ,
Regards,
Shwetha
Ok , I got the answer for the above question.
In XPAND , the expressions are not allowed to pass as parameter. But this is done in XTEND 2
Related
I inherited some old Cocoon code, if it's obvious, please tell me where in the docs I could find it.
I have a function to clean up some page parameters. I want to hand over the content to that function, but I can't manage to get there.
This is the original code, the value must pass my "cleanPath" function.
<jdbp:page-param name="pageToLoad" value="${{request.requestURI}}/../{#page}"/>
Attempt 1:
<jdbp:page-param name="pageToLoad" value="cleanPath(${{request.requestURI}}/../{#page})"/>
My attempt was to add the function in and leave everything like that, but it's not working.
My next attempt is these nice xsp:logic blocks, where I can't get the requestURI. "request.requestURI" is unknown, evaluate complains
"Type mismatch: cannot convert from Object to String".
<xsp:logic>
String input2 = evaluate("${{request.requestURI}}", String.class);
String input = "/../<xsl:value-of select="#page"/>";
putVariable("Hase","Test "+input);
</xsp:logic>
<jdbp:page-param name="pageToLoad" value="${{request.requestURI}}/../{#page}"/>
<jdbp:page-param name="Hase" value="${{Hase}}"/>
It's easy to just call request.getRequestURI();. No need for complicated wrappers.
drl file :
rule "pendingMsgSizeModified"
when
$tibcoEMSObj : TibcoEMSData(deliveredMsgCnt.contains("MB") && pendingMsgSize \> 100)
eval (!($tibcoEMSObj.typeOfAlert != null))
then
$tibcoEMSObj.setSendEmail(true);
$tibcoEMSObj.setTypeOfAlert($tibcoEMSobj.getTypeOfAlert()+"pendingMsgSize###");
update($tibcoEMSObj)
end
It gives error at this location : $tibcoEMSobj.getTypeOfAlert()
Error : \[Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.$tibcoEMSobj()\]
\[Near : {... SObj.setTypeOfAlert($tibcoEMSobj.getTypeOfAlert()+ ....}\]
I am expecting to use the getter method to get it and concatenate the string to set in another variable and save/update it
Your syntax is all over the place. And without actually seeing your model, it's hard to tell what you're even trying to do.
But based on what you said:
I am expecting to use the getter method to get it and concatenate the string to set in another variable and save/update it
And the code you did provide, I think this is what you're trying to do:
rule "pendingMsgSizeModified"
when
$tibcoEMSObj : TibcoEMSData(
deliveredMsgCnt.contains("MB"),
pendingMsgSize > 100,
$alertType: typeOfAlert != null
)
then
String newAlert = $alertType + "pendingMsgSize###";
modify($tibcoEMSObj) {
setSendEmail(true)
setTypeOfAlert(newAlert)
}
end
I presumed that your eval was either typo'd or just plain wrong since it was checking that the value was actually null. Don't use eval unless you have absolutely no other choice. (And I've never actually run into a situation where there was no other choice.)
I also presumed that the alert type will not change. I don't know what your sendEmail method does, or if it has side effects; if it does have side effects that change the typeOfAlert, then you'll of course need to call getTypeOfAlert() after calling setSendEmail.
I'm trying to set a string to receive a value from other elements. I'm currently using selenium java. I don't understand why I get NullPointerException.
The method used for setString is that,
public void setString(String name, String value) {
this.configuration.setString(name, value);
}
Basically, this method set using HashMaps.
But when I use debug mode on IntelliJ
element(EXAMPLE_1).getText()
I get that:
That's the string that I want to save.
But when I do :
setString(VAR_EXAMPLE, Selenium.getInstance().getCurrentDriver()
.findElements(By.xpath(EXAMPLE_1)).getText())
I get this error
Can anyone help me out? Really appreciate :)
Can you try with findElement instead of findElements, get Text is only applicable on particular element not on all elements
.findElement(By.xpath(EXAMPLE_1)).getText())
I create one text message i.e.
"vishal is working as developer, since $obj.object[0].timeStamp"
if timeStamp is null then String should replace with
"vishal is working as developer"
So I tried like
"vishal is working as developer, #if ($obj.object[0].timeStamp) , since $obj.object[0].timeStamp" #end
it is not working please help me out
Have you got getters?
Please read this: How to access an object's public fields from a Velocity template
If I were you maybe I would pass the $obj.object[0].timeStamp to the velocity not only the $obj. (Especially if you need only this value from the object)
Finally for checking the null I think soorapadman's answer is perfect.
I want to read/extract the value from HSSFComment.
I can access the HSSFComment by the following code:
HSSFComment comment = workSheet.getCellComment(1, 0);
But, how can I get the text/value from that "comment" instance?
there are tow methods in HSSFComment:
getTextObjectRecord()
getNoteRecord()
But both are protected methods...that's why I can't access those from my class. in other word, these methods are not visible from my class. Following line of code doesn't compile.
TextObjectRecord txo = comment.getTextObjectRecord();
Any comments?
Use getString() inherited from HSSFTextBox. This returns an HSSFRichTextString, which itself has a getString() method to get the plain text. In otherwords
String comment = cell.getComment().getString().getString();
Which you can't do like that due to the possibility of null returns, but that's the idea.