Struts1 Action Parameters Use and Working - struts

I am new to Struts and I Don't Understand Struts Action Parameters, specifcally: Name,Validate,Input and Redirect="true"
Example:
*#struts.action name="activation" path="/activation" validate="false" parameter="activation"
*#struts.action-forward name="activationStart" path="/activation.html" redirect="true"
Please try to answer me in terms of above example.

So basically you refuse to read the Struts 1 documentation?
name
The name of the ActionForm bean for this action.
validate
Should validation run?
input
The input page for the form, usually used to return to the form on a validation error.
redirect
When this forward is returned should it be a redirect or a forward?

Name
Name is the name of the formbean which is associated with you JSP. In your struts-config you will have something like this
<form-beans>
<form-bean
name="activation">
<form-property name="name" type="java.lang.String"/>
</form-bean>
</form-beans>
validate
You have validator framework which has some validations in place, like checking the name field for null value and so. You tell your struts whether the validator should work or not. If validation=false, then validation is not performed in your current jsp
input
input is the input jsp. If there are any validation errors, the execute method of the action will not get called; instead the control will go back to that ***.jsp. But you have not specified any input in your example
redirect
Whether to redirect or just forward

Related

Sailsjs Waterlock - Set up multiple auth methods

I have been learning how to use SailsJS most effectively, which includes using authentication. After the nightmare that sails-auth gave me, I decided to use Waterlock.
I have a default setup with Waterlock. I am trying to use multiple auth strategies (waterlock-local-auth + waterlock-google-auth).
Whenever I POST credentials to the register page, I am presented with
HTTP 400: you must specify a type parameter.
After reading the code, I notice I must submit an authentication type string with my form submit. So I add <input type="hidden" name="type" value="waterlock-local-auth"/> to the form. However, now I am presented with this:
HTTP 400: unknown/invalid authentication type
Why?
The proper way to encode the type string in the form data this way:
Your auth package name is waterlock-x-auth
The value on the input tag should be x
The input tag (if using local, for example) would look like this:
<input type="hidden" name="type" value="local"/>

Struts 2 property not being read from properties file

After following the struts 2 web pages and numerous examples, my application still will not pick up values from the struts.properties file.
I am trying this in order to give some values a money type format:
<s:property value="getText('struts.money.format',{value})" />
My struts.properties file which is under WEB-INF/classes and therefore visible has the following single line
struts.money.format= {0,number,\u00A4##0.00}
I get the string struts.money.format printed to the screen. If I change the first parameter of the getText call, the new string I put also will get printed instead of a true lookup happening.
If I do <s:property value="value" /> I will get back a proper number. If I drop the second argument on the getText call, I would expect to get back the right hand side of the assignment in the properties file, but i get the same struts.money.format back.
I am using Tomcat 6 with Struts 2.2.1.1. Is there an additional part of the puzzle I am possibly leaving out?
So in my struts.xml file, I put this line
<constant name="struts.custom.i18n.resources" value="struts" />
It needs this to know that I am trying to use a struts.properties file. I had assumed that by default a file named struts.properties was along the chain of places to look for a constant such as this. Only if you named it something else did you need to specify that. Even though it is in WEB-INF/classes which is recommended by the Struts 2 documentation, it just simply was not looking in this file.
EDIT
For what it is worth, I also had to modify my struts text tag like so
<s:property value="getText('struts.money.format',{#java.lang.Double#valueOf(value)})" />
Actually, value should have been a BigDecimal, but it was being treated at the view level here as java.lang.String. The problem is that some of the String objects had exponential formatting (like 1.642E07 or something to that effect) and the struts formatter could not handle the exponential formatting. The valueOf eliminates this exponential fomatting

struts form and JSTL

How to access a form variable using JSTL ?
e.g.
<html:text property="abc" ... />
<c:out value="${abc}"/>
abc is always blank, even though I have value set by action sending to this page.
If you refer with ActionForm, you can retrieve the value. "abc" is one of the property of ActionForm(you created) which will be available in request scope as it has been set in ActionServlet during processing request.
So get the value like this, suppose your ActionForm is 'TestForm', then retrieve as ${TestForm.abc} or <c:out value="${TestForm.abc}"/>

Struts 1.x tags usage question

I have a jsp page with the tags:
<logic:iterate id="var" ...
....
<bean:write name="var" property="p1" ...
etc.
And I need, on each iteration, to generate a href composed from the various bean's properties. I even need to URLEncode some of them so the link works.
Something like
<logic:iterate id="var" ...
....
<html:link action="otheraction.do?_X_
<bean:write name="var" property="p1" ...
etc
where X is generated by collecting the bean's properties; something like
String X="p1="+URLEncode(p1)+"&p2="+SimpleDateFormatof(p2)+"&p3="+p3;
How can I do that ?
Thanks in advance.
Better to make one POJO class.
1. Assign all your values to the object in Action which is being called before your jsp page comes in the picture.
2. Keep the object of POJO to request attribute.
3. Get the value from request attribtue on JSP using <bean:write> tag.

Refining my Dojo/Dijit NumberTextBox numeric validation

I have the following code:
<input type="text" dojoType="dijit.form.NumberTextBox" size=8
constraints="{min:0,max:100000,places:0}"
id="orgNumberOfStudents" name="orgNumberOfStudents"
required="true" invalidMessage="Integer between 0 and 100,000"
value="">
Questions:
1) How do I set the width of the box? Do I have to do it in a style tag or a CSS? Is the traditional "input size" tag ignored?
2) The above sample shows the error when I type in a non-numeric value. But if I tab over the field and don't fill in anything, it's still blank. Is there a quick way to enforce the validation when I click the submit button? Do I need a Dijit submitt button? Do I need to write more JavaScript to make this happen? How does the required="true" actually occur?
(One get-around is to set the value to 0, but I'd rather force the user enter a value rather than just defaulting it).
Thanks,
Neal Walters
You should be able to use both CSS and traditional INPUT attributes like "maxLength" on your NumberTextBox by passing them in to the Widget's constructor. maxLength is available on all dijit.form.TextBox subclasses, but is probably less useful here since you have control over things like min/max and the actual number format.
Yes, you can always write your own JS to test "isValid()" on your widget instance before submission, e.g. in an HTML FORM onSubmit handler, or you could use dijit.form.Form which will check validity for you. The widget itself is only responsible for visual representation of its own validity, according to the options chosen.
HTH