CKeditor uploads in Struts2 - struts2

I have specified in struts.xml all the options for editor:
<constant name="struts.ckeditor.allowUploads" value="true" /> <!-- default is false -->
<constant name="struts.ckeditor.allowedFileExtensions" value="jpg,jpeg,png,gif" />
<constant name="struts.ckeditor.uploadFolder" value="/userfiles/images/" />
and added attribute "uploads="true"",
but the server doesn't appear, as in the example on the oficial page of it http://ckeditor.com/demo, only the "Send to Server" button persist.
And why the default upload folder in the input is still "uploads/" if I specified it in the config file as "/userfiles/images/"?
screehsot http://img141.imageshack.us/img141/7673/screenshotat20120228100.png
I missed something?

Related

Underscores and wildcard action mapping in Struts 2

I'm working with a Struts 2 webapp with the following action mapping:
<action name="something_*" class="foo.whatever.MyAction" method="{1}">
<result>blah/myJsp.jsp</result>
...
</action>
So if I load the URL /something_load.action, it calls to MyAction.load(), and so on. Piece of cake. What puzzles me is that loading /something.action does work too (I guess it's invoking the execute() method). How is it possible? My action mapping is supposed to match "something_", but there is no underescore in my URL. It should give me an error! Shouldn't it?
I've double checked that there isn't another mapping for "something.action" in the struts config files. I also checked the web.xml file, just in case...
The only explanation that I can imagine is that the underscore is ignored in Struts if I use wildcard mappings. But then it would make no difference to load /something_load.action, /some_thing_lo_ad.action... and that's not true.
I'm aware that this must be a very noobish question, but I've been unable to solve the mistery, neither looking through Stackoverflow questions nor the Struts documentation.
This is the main struts.xml file:
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.freemarker.templatesCache" value="true" />
<package name="default" extends="struts-default">
<!-- interceptors ... -->
<!-- global results for error pages -->
</package>
<!-- lots of includes -->
</struts>
It appears that wildcards are matched loosely in order to support some legacy syntax. So the issue isn't with underscore but with loose matching pattern.
From the javadocs:
Patterns can optionally be matched "loosely". When the end of the pattern matches \*[^*]\*$ (wildcard, no wildcard, wildcard), if the pattern fails, it is also matched as if the last two characters didn't exist. The goal is to support the legacy "*!*" syntax, where the "!*" is optional.

How to prevent the wildcard namespace in struts?

I am facing a problem that I couldn't find a key word for googleing the following situation:
<package name="Main" namespace="/" extends="struts-default">
<action name="administrator" class="com.xyz.AdminAction">
<result name="success">/WEB-INF/jsp/admin.jsp</result>
</action>
</package>
The above url should be http://xyz.com/administrator and it works fine. However, if I change the url to http://xyz.com/asdasd/asdasdasd/administrator and it still works, but I can't accept this! So any setting to tell struts only http://xyz.com/administrator is accepted? Thanks!
Set the alwaysSelectFullNamespace property to true.
From struts-default.properties:
### Whether to always select the namespace to be everything before the last slash or not
struts.mapper.alwaysSelectFullNamespace=true
XML configuration is preferred, so in your struts.xml:
<struts>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="true" />
...

WiX Burn bootstrapper cancel dialog localization

I have successfuly created a localized installer and bootstrapper setup using WiX. There is just one problem with the bootstrapper localization. Everything is fine except the values of button captions in a dialog that appears when the installation is being canceled (exit confirmation yes/no). There are no string elements in the bootstrapper theme wxl files that would allow to change these values. In the MSI installer this was possible by setting "WixUIYes", "WixUINo" values.
I have tried to add the following elements to my localized theme file, but without success.
<String Id="WixUIYes" Overridable="yes">some_value1</String>
<String Id="WixUINo" Overridable="yes">some_value2</String>
Is there a way to change the caption values of mentioned buttons? Their values are currently in the system language.
This is my WXS file:
<?xml version='1.0' encoding='windows-1250'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="Test" Version="1.0.0.0" UpgradeCode="MY-GUID">
<WixVariable Id="WixStdbaThemeXml"
Value="Resources\HyperlinkTheme.xml" />
<WixVariable Id="WixStdbaThemeWxl"
Value="Resources\LocalizedHyperlinkTheme.wxl" />
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" >
<bal:WixStandardBootstrapperApplication LicenseUrl="" SuppressOptionsUI="yes" />
</BootstrapperApplicationRef>
<Chain>
<ExePackage Id="VCRedistExe"
Cache="no"
Compressed="no"
Vital="yes"
SourceFile="vcredist_x86.exe" />
<MsiPackage Id="MyAppMsi"
Cache="no"
Compressed="yes"
Vital="yes"
SourceFile="MyApp.msi"
DisplayInternalUI="yes" />
</Chain>
</Bundle>
</Wix>

no effect of "resultpath" constant in struts.xml

I have all the jsp pages (ex: index.jsp) in the WebContent folder and my application is working smoothly.
Now, I created a folder "pages" inside WebContent, where I transferred all my jsp pages.
And I added the following line inside the <struts> tags:
<constant name="struts.convention.result.path" value="/pages" />
But still, its not searching for jsp inside the "pages" folder.
I am getting:
HTTP Status 404 - /MyApplicationName/index.jsp
Where am I doing a mistake?
EDIT: The current structure of my application is as follows:
The welcome page is an action instead of a jsp page. The result page of this action is index.jsp. This action populates the dropdown menu and some other fields in index.jsp. Now, I want to keep index.jsp along with other jsp pages in the folder "WebContent/pages". I have over 30 jsp pages in my application, and I don't want to mention the full path of every jsp in the result-tag. Thats why I want to make use of the struts2 constant "struts.convention.result.path"
My question is, why the code I have mentioned above is not working?
Accessing index.jsp directly bypasses all S2 request handling.
There's no S2 or S2 Convention plugin involved, you're just accessing a JSP page.
If index.jsp is first page of your application then you need to change its path to /pages/index.jsp in <welcome-file> tag of web.xml. And for rest I agree with #Dave Newton :)
Probably your mistake was in struts.xml.
When you create a new-Folder under web-content make with the same name (folder-name) of
xml file under src and include it in struts.xml file it will work fine.
For eg: suppose you created example folder under web-content, now create example.xml file
under src folder and in struts.xml file include example.xml
example.xml:
<struts>
<package name="example" namespace="/example" extends="default">
<action name="your action name" class="your class" method="your method">
</action>
</package>
</struts>
struts.xml:
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<action name="" class="" method="">
</action>
</package>
<include file="example.xml"/>

Struts 2 - There is no Action mapped for namespace [/] and action name [validateLogin] associated with context path [/LoginApplication]

I tried out all the possible solution available on the internet.
error :
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [validateLogin] associated with context path [/LoginApplication].
struts.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="hello" extends="struts-default">
<action name="validateLogin"
class="com.example.login.ValidationAction"
method="execute">
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
index.jsp
<form action="validateLogin">
<table>
<tr>
<td><label for="username">Username</label></td><td><input type="text" name="username"></td>
</tr>
<tr>
<td><label for="password">Password</label></td><td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Login"></td>
</tr>
</table>
</form>
The solution to my problem was a little weird.
i just removed <constant name="struts.devMode" value="true" /> from the struts.xml file
and the program started working properly... and then i placed the same code back again in the struts.xml file and it was still running....
Make sure that struts.xml is in the right directory.
If you are using Eclipse, you can follow these steps :
1- Right-click on the project ⇾ properties ⇾ Deployment Assembly.
2- Make the deploy Path of your sources like this: screenshot1
-/Src/main/java : WEB-INF/classes.
-Struts2(library) : WEB-INF/lib.
3- Put the struts.xml in the directory which have a deploy Path withe WEB-INF/classes.
For example here you should put it in /src/main/java.screenshot2
This error comes mostly when the package structure is not made correctly.
If the web.xml file and struts.xml file is created under correct package then both the XML files will be reflected automatically under Configuration files folder structure in Netbeans.
Please refer the screenshot:

Resources