struts 1.1 tiles inside html:form - struts

Hello I had a form that looks like this:
<form target ="_blank" id="downloadFrm" name="downloadFrm" action="<tiles:getAsString name="downloadFileName" ignore="true"/>" method="post">
But I want this form to be a html:form, something like:
<html:form target ="_blank" styleId="downloadFrm" action="<tiles:getAsString name="downloadFileName" ignore="true"/>" >
But I can't have the "!tiles.getAsString inside the html:form.
I get equal symbol expected.
Can this be fixed?

Please try to assign the action to variable as follows and use it in html:form
<c:set var="actionPath"><tiles:getAsString name="downloadFileName" ignore="true"/></c:set>
<html:form target ="_blank" styleId="downloadFrm" action="${actionPath}" />

Related

Pass info between tag helpers?

I am writing a set of tag helpers that target, for example, <form> and <input> elements. I want to add a custom attribute to the <form> element, and retrieve the value of that attribute in the contained <input> element. So, if my HTML looks like this:
<form xx-value='123'>
<input asp-for='Something' />
</form>
then in my InputTagHelper I would want to retrieve the value 123 that was specified for the xx-value attribute.
Is there a designed-in way to pass data like this between tag helpers?
Consider the case where I have this markup:
<form xx-value='123'>
<input asp-for='Something' />
</form>
<form>
<input asp-for='SomethingElse' />
</form>
In this case, the first invocation of the InputTagHelper would get the value 123. But the second invocation of the InputTagHelper would get a value of 0 since its parent <form> tag didn't specify the magic xxx-value attribute.
The simple answer (which doesn't work for <form> and <input> tags - see blow) is for the "parent" tag helper to store the value in the context.Items dictionary and for the "child" tag helper(s) to retrieve the value from that same dictionary. A Google search for "child tag helper" yields many examples of this scheme.
The problem with this answer (in the context of the OP) is that, for some reason, the <form> tag helper executes after its child <input> tag helper. So, rather than receiving the value from the parent FormTagHelper, the InputTagHelper discovers that the context.Items dictionary is empty.
I created this SO post to ask about that weird behavior.

How can i auto get form's data for perl6?

a form like this:
<form action='1.php' method='post'>
u:<input name='u' type='text'/><br />
p:<input name='p' type='password'/><br />
<input value='submit' type='submit'/>
</form>
and how can i auto get the form data use perl6?
lkie this:
my $form = xxx($the_form_url)
and the result like this:
$form.Str
#output like that:
#u=username&p=password&submit=submit
have shome modules in perl6?
please..
Bailador is indeed a good tip.
But if you want a more CGI-line approach, have a look at SCGI;
https://github.com/supernovus/SCGI

ModX Eform: Captcha not generating image

I am trying to get CAPTCHA working on the eForm plugin. I have added the input form field:
<label for="cfCaptcha">Captcha:<br />
<img src="[+verimageurl+]" alt="verification code"><br />
<input id="vericode" name="vericode" class="text" type="text">
and I have added
&vericode=`1`
to the eForm call.
and have added the Template Variable [+verimageurl+] to my template.
However, when I preview the form all I see in the image area is <img src="" alt="verification code">
Would anyone know what I am doing wrong?
Did you get this fixed?
Check that you ended the label code. Run it through w3c code checker too.
A few times I have left a element un-closed and it breaks the whole thing.

Disabling radio button in jsp based on map value struts2

I'm trying to use a boolean value returned from a map in my bean to either disable/enable a radio button in a jsp page.
Class snippet:
public class Options{
private String optionId;
private Map<String,Boolean> negativeMap;
public setNegativeMap(Map<String,Boolean> negativeMap){
.......
}
JSP snippet:
<input id="radioClick<s:property value=optionId"/> type="radio" disabled="%{negativeMap[optionId]}" />
Am I on the right track with this? Is there something I'm missing?
Please, I think your JSP snippet was wrong near "value=optionId"/>" :
<input id="radioClick<s:property value=optionId"/> type="radio" disabled="%{negativeMap[optionId]}" />
Your JSP snippet should be like this :
<input id="radioClick<s:property value=optionId/>" type="radio" disabled="%{negativeMap[optionId]}" />

Multiple Submit button in Struts 1.3

I have this code in my JSP:
<%#taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
..
..
<html:form action="update" >
..
..
<html:submit value="delete" />
<html:submit value="edit" />
<html:sumit value="update" />
</html:form>
And this in the struts-config.xml file:
<action path="/delete" name="currentTimeForm" input="/viewall.jsp" type="com.action.DeleteProduct">
<forward name="success" path="/viewall.jsp" />
<forward name="failure" path="/viewall.jsp" />
</action>
Like the delete action, I have edit and update. It works fine, if I give the name specifically like <html:form action="delete"> but, how to make it dynamically work for update and edit?
You have one form and multiple submit buttons. The problems is that a form can only submit to one action, no matter how many submit buttons you have inside the form.
Three solutions come to mind right now:
1. Have just one action where you submit everything. Once inside the Action class check what button was used to submit the form and perform the appropriate treatment based on that.
<html:form action="modify">
..
..
<html:submit value="delete"/>
<html:submit value="edit" />
<html:sumit value="update" >
</html:form>
In the ModifyAction.execute(...) method have something like:
if (request.getParameter("delete") != null || request.getParameter("delete.x") != null) {
//... delete stuff
} else if (request.getParameter("edit") != null || request.getParameter("edit.x") != null) {
//...edit stuff
} else if (request.getParameter("update") != null || request.getParameter("update.x") != null) {
//... update stuff
}
2. Have the action attribute of the HTML form changed using JavaScript before submitting the form. You first change the submit buttons to plain ones with click handlers attached:
<html:form action="whatever">
..
..
<html:button value="delete" onclick="submitTheForm('delete.do')" />
<html:button value="edit" onclick="submitTheForm('edit.do')" />
<html:button value="update" onclick="submitTheForm('update.do')" />
</html:form>
With the handler:
function submitTheForm(theNewAction) {
var theForm = ... // get your form here, normally: document.forms[0]
theForm.action = theNewAction;
theForm.submit();
}
3. Use a DispatchAction (one Action class similar to point 1) but without the need to test for what button was clicked since that's treated by the DispatchAction.
You just provide three execute methods properly named delete, edit and update. Here is an example that explains how you might do it.
In conclusion: For number 1, I don't really like those ugly tests.... for number 2, I don't really like the fact that you have to play with the action form using JavaScript, so I would personally go for number 3.
There is another simpler way to do this as follows:
In the ActionForm currentTimeForm, add a String property (example: buttonClicked).
In the jsp, in each of the html:submit tags add this property.
Now in the action execute method simply check the value of this property, ie.
if(currentTimeForm.getButtonClicked().equals("delete"){
}
else if((currentTimeForm.getButtonClicked().equals("edit"))
and so on...