Struts 2 cannot resolve java action method in # tag - struts2

There's something I'm been missing in how Struts resolve ftl tag,
I have an action with some methods that I'm trying to call from my ftl.
The signature:
<#s.property value="%{someJavaMethod(someVariable)}>
is working fine, but the directive
<#include someJavaMethod(someOtherVariable)>
is giving me this:
----: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> someJavaMethod
and I cant figure out why, since, based on my limited knowledge of struts the signature # has access to the context Map where action properties and methods are stored.
NB: I checked that the problem is not in the someJavaMethod since debugging the code it doesn't even enter into.

You should reference the action to call its method in Freemarker. It is supported by the Struts 2 framework.
<#include action.someJavaMethod(someOtherVariable)>

Related

#Html.DeleteConfirmation in a Plugin View (Admin) in asp.net core 2.0

Looking at core code examples of say... Edit Action for SpecificationAttribute. I am looking to replicate this delete function in the same manner in my plugin, however, getting an error.
Getting this error
'IHtmlHelper' does not contain a definition for 'DeleteConfirmation' and no extension method 'DeleteConfirmation' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I have used in 3.90 but it getting error in 4.0 asp.net core Has anyone used #Html.DeleteConfirmation in a plugin (on administration side) that could give me a clues
I have a span element in the html like the following;
<span id="myattribute-delete" class="k-button">#T("Admin.Common.Delete")</span>
And trying to use #Html.DeleteConfirmation("myattribute-delete")
I know I probably need to double check my route, by the error is leading me to think the issue is not a routing issue.
As #Stephen stated it's not part of MVC, and it's custom helper by nopCommerce.
#Html.DeleteConfirmation is helper till/in nopCommerce 3.90, but in 4.0 it has been changed to
<nop-delete-confirmation asp-model-id="#Model.Id" asp-button-id="myattribute-delete" />
And that helper located at Nop.Web.Framework.TagHelpers.Adminso you have to add reference of it to your view file.

grails #Resource Annotation before Domain class

When I create a RESTful API in Grails, I add #Resource(uri='env',formats=['multipart/form-data'] before the domain class. And then use grails generate-all domain_name to generate the controller and view.
However, in Eclipse there is an Java problem like
The project was not built due to "RequestEnvironmentController$_on_closure51 [in [Working copy] RequestEnvironment.groovy [in test.environment.manager [in grails-app/domain [in restful-api-for-tem]]]] does not exist". Fix the problem, then try refreshing this project and building it since it may be inconsistent.
Then I get rid of the annotation and the error disappears and the post method still works. I am confused, is the annotation necessary or not? If it is necessary, how can I remove the Java error?
When you use the #Resource annotation there is no need to create a controller because this will be automatically generated as per documentation
Simply by adding the Resource transformation and specifying a URI,
your domain class will automatically be available as a REST resource
in either XML or JSON formats. The transformation will automatically
register the necessary RESTful URL mapping and create a controller
called BookController.

How to add custom fields in ZFC-user module for zend 2 without doctrine?

I have tried using creating a different module and attaching the ZfcUser\Form\Register over init method. But it wasn't working.
I want to add few custom fields, with changing any thing in the vendor dir, as is it not a good practice. I also tried using user_entity_class ,creating a custom 'User' class, but it was creating some route issue in other modules, with zfc-user , I'm also using zfc-admin and zfc-adminuser, the error was coming in zfc-adminuser, Couldn't found the class was the error.
Thanks in advance.
Well there are some issue regarding the overriding of the module ZFC-User, But still you can overwrite it manually.
One way I have used is a bit old fashioned but working. What I have done is I have copied complete module the to module folder. Then pointing the form towards to my module where the changes are required, rest all are pointed to default.With this you can update your module. Make sure you point the user_entity_class to your module something like this:
'user_entity_class' => 'MyZfcUser\Entity\User',
you can find this in config\autoload\zfcuser.global.php

Orchard Contrib.DateTimeField missing style and script

`I've installed the DateTime Field module to Orchard and assigned two fields to my custom part, but when navigating to the Admin Edit page for the custom type implimenting the custom part, I recieve an error like this:
A 'stylesheet' named 'jQueryUtils_TimePicker' could not be found.
When looking in the Contrib.DateTime.cshtml View, I find that the following two resources are required, but I can't find them in the jQuery module's resource manifest.
Style: jQueryUtils_TimePicker
Script: jQueryUtils_TimePicker
Where are these meant to be defined and stored?
Thanks in advance.
P.S.
If I change both to jQueryUI_TimePicker (for which there is a script and style defined in the jquery module resource manifest), then it doesn't throws an error, but the time picker doesn't work.
Contrib.DateTimeField is obsolete since 1.4 so you shouldn't use it.
The DateTimeField has been integrated in Orchard.Fields has a core feature.

T4MVC renderpartial and Spark views

#Html.RenderPartial(MVC.Shared.Views._Sorter);
throws error =>
There is no build provider registered for the extension '.spark'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: There is no build provider registered for the extension '.spark'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Any ideas what might be wrong?
Adding this to web.config=>system.web=>compilation
<buildProviders>
<add extension=".spark" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
Forces app to build spark view as webforms view and produces ${Something.something} all around. So - what's an equivalent for spark viewengine?
Can you please try to make the following change to T4MVT.tt. In the method ViewsFolderInfo.AddView, change the line:
Views[viewFieldName] = GetVirtualPath(item);
to
Views[viewFieldName] = viewFieldName;
If that works well, we can just add a switch to the settings file that makes it do this instead of the default full path.
Let me know how that goes!
Note that MVC.Shared.Views._Sorter is just a constant with the path to the view. If you were to write this code without T4MVC, what exact string would you pass in there?
Maybe Spark has different requirements in the type of view paths it accepts here? If needed, we can tweak T4MVC to make this work, but I'd like to fully understand the Spark behavior outside of T4MVC first.

Resources