Argument type of parameterized method call in EL - el

I was making a method call objectMapper.writeValueAsString in EL like this.
<%# attribute name="actionItems" required="true" rtexprvalue="true" type="java.util.List"%>
<jsp:useBean id="objectMapper" class="org.codehaus.jackson.map.ObjectMapper" scope="page" />
<jsp:useBean id="actionItemsMap" class="java.util.HashMap" />
<c:set target="${actionItemsMap}" property="actionItems" value="${objectMapper.writeValueAsString(actionItems)}" />
writeValueAsString takes an Object parameter in method signature. It was working when I pass in actionItems which is an ArrayList.
Now I am upgrading my ApacheTomcat 7 from 7.0.52 to 7.0.70, and the code is broken with MethodNotFoundException:
javax.el.MethodNotFoundException: java.lang.NoSuchMethodException: org.codehaus.jackson.map.ObjectMapper.writeValueAsString(java.util.ArrayList)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:422)
at org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:139)
It is trying to find a method writeValueAsString with argument type ArrayList. It seems related to this change in 7.0.53. How should I change my code to make it work? Do I have to make the method call with an Object argument? If so, is there a way I can cast the ArrayList to an Object in EL and then make the method call?

Turns out this is an issue on our side. These parameterized method calls are supported.

Related

Laravel Blade question: how do you dynamically set the field name for #error directive within a component

Fairly basic question as I'm going back to webdev after a few years away so experimenting.
I want to create a reusable component that wraps an error message in a formatted element:
I'd call it in my partial as...
<x-error :blah="$woof"/>
The component code would be something like this:
#error('field') "nicely formatted message" #enderror
However, I want to be able to dynamically set the field name within for the error directive, something like:
#error($field) or #error({{ $field }}) "nicely formatted message" #enderror
...while in the executing partial it would be called through something like:
<x-error :field='email'> or <x-error :field='password'> or <x-error :field='description'> or whatever field name you like.
After spending way too long trawling the web for clues I'm starting to suspect this isn't possible.
Is it? If so how do you do it? Any help or clues gratefully received
Cheers!
The answer is embarrassingly simple: leave off the semicolon! The semicolon kinda acts like a pointer to a variable, rather than passing the data directly to the component, so instead of:
<x-error :field="$title" />
It should be :
<x-error field="title" />
In the component you merely call the variable name:
#error($field)
"nicely formatted message"
#enderror
Easy, init?

How to pass parameter to service call?

In the PopCommerce's Detail.xml there is a parameter productId being passed to screen. How do I pass that parameter to service-call ?
I have tried below code in service call but this doesn't work
<field-map field-name="productId" from="productId"/>
The parameter in the screen is
<parameter name="productId" required="true"/>
and the service I have defined is
<transition name="createProductReview">
<service-call name="create#ProductReview" web-send-json-response="true">
<field-map field-name="productStoreId" value="POPC_DEFAULT"/>
<field-map field-name="productId" from="how do I use the productId parameter here ?"/>
<field-map field-name="userId" from="ec.user.userAccount.userId"/>
<field-map field-name="statusId" value="PrvwPending"/>
</service-call>
<default-response type="none"/>
</transition>
The line you mentioned is the correct approach, all parameters are put into the context and can be used as fields from there. To be specific, this line:
<field-map field-name="productId" from="productId"/>
Note that you can use the in-map with the Groovy Map syntax ([:]) for these as well, and it's a bit cleaner.
If that isn't working then the issue is most likely that the productId isn't being passed to the request that calls the transition.

Sending Property Value to Wix Extension Method

I have a wix property
<Property Id="VAR1" Value="aValue" />
And i want to send this value into my Extension method
<Property Id="TEST" Value="$(extension.GetResult(VAR1)" />
I want to send the value aValue into the GetResult method, but cant seem to find
the correct syntax to convert VAR1 to 'aValue'
The extension is a preprocessor extension and the Property VAR1 will get set via the user interface...
Properties are only available at runtime, other than by parsing source itself.

GridView Updating on ItemCommand

i put all my custom "update" code in the RowCommand event, it works fine, but i still get an error from my Data Source
System.NotSupportedException: Updating
is not supported by ObjectDataSource
'GetSources' unless the UpdateMethod
is specified.
how can i get rid of that error , yes still use my custom update code on the rowcommand?
Well, I think the way the ObjectDataSource is intended to be used is you specify the name of the method in your custom business object, and it will use reflection to call that method.
So, your page and object might look something like this:
<asp:objectdatasource
id="ObjectDataSource2"
runat="server"
updatemethod="MyUpdateMethod"
typename="MyBusinessObject">
<updateparameters>
<asp:controlparameter name="anID" controlid="DropDownList1" propertyname="SelectedValue" />
</updateparameters>
</asp:objectdatasource>
Public Class MyBusinessObject
Public Shared Sub MyUpdateMethod(anID As String)
'data access code
End Sub
End Class
This pattern of putting control together can be quite productive, but you'll probably feel too restricted after a while.

How to use a property that was set in a custom action?

I want to set a property in a custom action and use it in the standard custom action "util:User" afterwards. But no matter where I put the property in my wxs-file, I always get "error LGHT0094 : Unresolved reference to symbol"
Details:
In my setup I want to add a new user by using util:User. The user should be added to the group "Power Users" by using util:GroupRef. No Problem so far. Unfortunately the group names are language dependent. In german "Power Users" is "Hauptbenutzer". So I want to look up the well known SID S-1-5-32-547 in a custom action, set a property in this custom action by calling MsiSetProperty and then use the property for util:GroupRef.
As far as I understand, the property must be declared somewhere in the wxs-file.
In the examples I found, the property was never declared as follows (but I also tried that):
<Property Id="TextSID" Value="Power Users" />
In the examples there always was a custom action to set the property, like:
<CustomAction Id="SetTextSID"
Property="TextSID"
Value="Power Users"
Return="check" />
My problem is, that the creation of the user fails to "compile" because the property "TextSID" is not known:
<Component Id="CreateUser" Guid="Some GUID here in my original wxs file">
<util:User Id="UserUser"
Name="User" Password="Password"
CanNotChangePassword="yes" PasswordNeverExpires="yes">
<util:GroupRef Id="TextSID" />
</util:User>
</Component>
I have never done a custom action before and I'm a new to WiX and MSI, so any idea would be very welcome.
Regards
Ralf
Sorry for wasting your time.
I stared at my XML for hours before I posted this question, just to find the answer immediately after my post :-(
My only problem was, that it is not possible to reference to something that isn't there. In this case the "util:Group" was missing.