please I have a problem with the parameters of an action. Can someone help me? I'll explain:
I have an action "Etiquette (string nom_pharm, int numBon, int nbColis)" in the "Etiquetage" controller. In the view I have two input text for numBon and nbColis, I try to get them back to pass them in parameter but always the second one indicates that it is null, I use this line:
<input type="button" value="Ok" onclick="window.location = '#Url.Action("Etiquette", "Etiquetage",new { nom_pharm = #Model.PharmacieNom, numBon = " ", nbColis = " " })'+parseInt(document.getElementById('in').value), +parseInt(document.getElementById('bon').value)" />
Do you have an idea of the correct syntax?
The relative url you need is /Etiquetage/Etiquette?non_pharm={value of in}&numBon={value of bon}&nbColis={value of in}
but your code is generating this /Etiquetage/Etiquette?non_pharm={value}&numBon= &nbColis= {value of in}{value of bon}.
Your approach is a bit strange. A more conventional approach would be to use a form with a POST rather than a GET. Assumming you have a good reason for using javascript here for sending a GET request this code should work.
<input type="button"
value="Ok"
onclick="window.location = '#Url.Action("Etiquette", "Etiquetage")?non_pharm=#Model.PharmacieNom&numBon='
+ document.getElementById('bon').value + '&nbColis='
+ document.getElementById('in').value" />
Note I have assumed that 'bon' goes with numBon and 'in' goes with nbColis.
Because you are creating a string the parseInts are not needed.
Related
How do I enclose a field name to postForm with RCurl when the form has fields like those below?
<input id="form:checkEstrato" type="checkbox" name="form:checkEstrato" checked="checked" />
<input id="form:checkArea" type="checkbox" name="form:checkArea" checked="checked" />
if I try something like
if(url.exists(url))
results <- postForm(url,
form:evento="35",
form:area = "10")
I get
> if(url.exists(url))
+ results <- postForm(url,
+ form:evento="35",
Error: unexpected '=' in:
" results <- postForm(url,
form:evento="
> form:area = "10")
Error: unexpected ')' in " form:area = "10")"
in fact it was simple, although now I have to work it out why Rcurl doesn't get what I want.
At least to avoid de above error it as just a matter of enclosing the parameter name with quotes
if(url.exists(url))
results <- postForm(url,
'form:evento'="35",
'form:area' = "10")
Now lets move ahead trying to understanding what is being sent to server and why its not working the way I expected.
I am trying to use Symfony 1.4's functional tests (sfTextFunctional) to verify the value of a textfield is as I expect. This is the html that is generated
<input type="text" maxlength="10" name="number_plant[1]" value="5" id="number_plant_1">
During the test I can set the value easily
setField('number_plant[1]', '5')->
And I have tried the following permutations of checkelement but they all return null
checkElement('number_plant[1]',"5")->
checkElement('number_plant_1',"5")->
checkElement('#number_plant_1',"5")->
checkElement('form input[type="text"][name="number_plant[1]"]',"5")->
Try something like:
checkElement('#number_plant_1[value="5"]')
EDIT: Apparently only this selector works as expected:
checkElement('form input[type="text"][name="number_plant[1]"][value="5"]')
(which is quite strange ;) )
This will check if an elemnt with id = "number_plant_1" and value = "5" exists on the page. As far as I know when you pass a string as the second parameter to checkElement it will try to match the content of the found element with the given string.
I want to show a custom message when user insert a wrong input for a Double value but when i test my application i always see the default error message.
That's my custom messages.properties:
`javax.faces.convert.DoubleConverter.CONVERSION=My Conversion Error(Double)
javax.faces.convert.DoubleConverter.CONVERSION_detail=My Conversion Error(Double)
javax.faces.component.UIInput.CONVERSION=My Conversion Error
javax.faces.component.UIInput.CONVERSION_detail=My Conversion Error(Double)
javax.faces.validator.NOT_IN_RANGE=My Validation Error
javax.faces.validator.NOT_IN_RANGE_detail=My Validation Error
javax.faces.validator.DoubleRangeValidator.LIMIT=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.LIMIT_detail=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.TYPE=Error Type Double
javax.faces.validator.DoubleRangeValidator.TYPE_detail = Error Type Double
javax.faces.component.UIInput.REQUIRED=Requested!!
`
And here my faces.config
`<application>
<message-bundle>it.exaple.messages.MyMsg</message-bundle>
</application>`
And here my page:
`<td>
<h:inputText id="Value" value="#{user.value}" required="true">
<f:validateDoubleRange minimum="0.0" maximum="200.0"/></h:inputText>
<h:message for="username" showDetail="true" showSummary="true" style="color:red"/>
</td>`
It's really strange because when i test my application with an empty value i can read my customized message, but when i try to insert a string i see the default error message!! Same thing happen when i put a to high or too low value!
Anyone can help me? Thanks!
I hope you must override these default message to validate range of double. And I hope you have defined user.value as double in your managed bean.
javax.faces.validator.DoubleRangeValidator.MAXIMUM
javax.faces.validator.DoubleRangeValidator.MINIMUM
javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE
I have a checkbox
<td><strong>Online Ordering: </strong></td>
<td><input type="checkbox" name="OnlineOrdering" value="<%=OnlineOrdering%>" <% if OnlineOrdering = True then response.write "checked='Checked'" end if %>/></td>
How do i capture whether the checkbox is checked or unchecked when form is submitted?
OnlineOrdering = request.form("OnlineOrdering")
this does not work?
This should assign a true/false to the variable OnlineOrdering:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
OnlineOrdering = (Request.Form("OnlineOrdering") <> "")
End If
I found this post because I was trying to solve the same problem. I have a solution that seems to work well.
In the HTML form, create dynamically generated checkboxes. The value of this_box_id used below can be any unique number. In my case it was the primary key (autonumber) for that question from the SQL Database . Dynamically generated the check boxes with an associated hidden field:
<input type="hidden" name="check_box_indicator" value="<%=this_box_id%>">
<input type="checkbox" name="box_id<%=this_email_selection_id%>"
value="<%=this_box_id%>">
When asp returns the values for this, it will return multiple values for check_box_indicator. Here's a sample query string snippet:
...&check_box_indicator=78&box_id78=78&check_box_indicator=98&check_box...
On the next page, ASP will read through the form data. It will find EVERY check_box_indicator and it's value. That value can be used to check the value of the associated checkbox. If that checkbox comes back, it was checked, if it doesn't you will know that it wasn't checked. In the sample above, checkbox 78 was checked and so the box_id78 value was passed, while checkbox 98 was not and box_id98 was not sent. Here's the code to use this.
For Each this_box_id In Request.Form("check_box_indicator") 'check EVERY box'
box_state = Request.Form("box_id"&this_box_id) 'collect passed values only'
if box_state > 0 then
store_value = "y"
else
store_value = "n"
end if
' you now have the this_box_id number identifying this item in the DB, '
' the value of the check box, if it was passed '
' and a definite y or n value '
Next
With the example querystring, you will get 78 y, 98 n
We've got an odd issue occurring with ColdFusion on BlueDragon.NET. Asking here because of the broad experience of StackOverflow users.
Tags inside POSTed content to out BlueDragon.NET server gets removed, and we're not sure where in the stack it's getting removed. So for example if we post this data
[CORE]
Lesson_Status=Incomplete
Lesson_Location=comm_13_a02_bs_enus_t17s06v01
score=
time=00:00:56
[Core_Lesson]
<sd ac="" pc="7.0" at="1289834380459" ct="" ><t id="lo8" sc=";;" st="c" /></sd>
<sd ac='' pc='7.0' at='1289834380459' ct='' ><t id='lo8' sc=';;' st='c' /></sd>
<sd ac="" pc="7.0" at="1289834380459" ct="" ><t id="lo8" sc=";;" st="c" /></sd>
<sd ac="" pc="7.0" at="1289834380459" ct="" ><t id="lo8" sc=";;" st="c" /></sd>
<b>hello1</b>
<i>hello2</i>
<table border><td>hello3</td></table>
<sd>hello4</sd>
<sd ac="1">hello5</sd>
<t>hello6</t>
<t />
<t attr="hello8" />
<strong>hello10</strong>
<img>
><>
What we get back is this:
[CORE]
Lesson_Status=Incomplete
Lesson_Location=comm_13_a02_bs_enus_t17s06v01
score=
time=00:00:56
[Core_Lesson]
hello1
hello2
hello3
hello4
hello5
hello6
hello10
>
That is, anything that starts with < and ends with > is getting stripped or filtered and no longer appears in ColdFusion's FORM scope when it's posted.
Our server with BlueDragon JX does not suffer this problem.
If we bypass using the default FORM scope and use this code, the tag-like content appears:
<cfscript>
// get the content string of the raw HTTP headers, will include all POST content as a long querystring
RAWREQUEST = GetHttpRequestData();
// split the string on "&" character, each variable should now be separate
// note that at this point duplicate variables will get clobbered
RAWFORMFIELDS = ListToArray(RAWREQUEST.content, "&");
// We're creating a structure like "FORM", but better
BetterFORM = StructNew();
// Go over each of the raw form fields, take the key
// and add it as a key, and decode the value into the value field
// and trap the whole thing if for some reason garbage gets in there
for(i=1;i LTE ArrayLen(RAWFORMFIELDS);i = i + 1) {
temp = ListToArray(RAWFORMFIELDS[i], "=");
try {
tempkey = temp[1];
tempval = URLDecode(temp[2]);
StructInsert(BetterFORM, tempkey, tempval);
} catch(Any e) {
tempThisError = "Malformed Data: " & RAWFORMFIELDS[i];
// Log the value of tempThisError here?
// WriteOutput(tempThisError);
}
}
</cfscript>
<cfdump var="#BetterFORM#">
If we do this, and use the created BetterFORM variable, it's there, so it does not seem to be a problem with the requests being filtered at some other point in the stack. I was thinking maybe it was URLScan, but that appears not to be installed. Since BD.NET runs on .NET as the engine, perhaps there's some sanitization setting that is being used on all variables somehow?
Suggestions, ideas, etc are welcome on this issue.
I don't have a BD.NET instance handy to check, but Adobe ColdFusion has a setting in the cf administrator to strip "invalid tags". That's my best guess. Adobe CF replaces them with "invalidTag", my guess is that BD.Net just strips it silently.
It turned out to be very mundane.
We had a custom tag that did customized string replacements. On one server, it was modified to NOT replace all tags. On this server, we were using an older version that did. So the fault was not a difference between BlueDragon JX and BlueDragon.NET -- it was developer team error.