Custom error in validation is not show in h:message - jsf-1.2

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

Related

BMC Remedy ticket status change error in asp net

I'm using MVC to manage the BMC ticket raise and resolve. However for certain groups there are additional fields that opens up after choosing the type of change as 'Resolved'
I tried input values to those fields but still I'm not able to resolve the incident.
Below is the code used,
StagingRequest.Incident_Nature = "NA";
StagingRequest.Network_Infrastructure = "NA";
StagingRequest.Incident_Element = "NA";
String ss = _WS1.HelpDesk_Modify(_AI1, StagingRequest.Incident_Number, StagingRequest.Type_of_Change, StagingRequest.Status_Reason, StagingRequest.Group_Name, StagingRequest.Assignee_Login_ID, StagingRequest.Resolution, StagingRequest.Incident_Nature, StagingRequest.Network_Infrastructure, StagingRequest.Incident_Element, StagingRequest.WorkLog_SupportDiary, StagingRequest.Work_Info_Notes, StagingRequest.Expiry_Date);
Note that I tried entering the actual dropdown values in those 3 fields still the same error "Unable to Modify :ERROR (100000308): ; Please choose the value for the following fields before resolving the ticket; 'Incident Nature', 'Network Infrastructure' and 'Incident Element'. "
The other groups for which additional fields is not required worked with the below code,
String ss = _WS1.HelpDesk_Modify(_AI1, StagingRequest.Incident_Number, StagingRequest.Type_of_Change, StagingRequest.Status_Reason, StagingRequest.Group_Name, StagingRequest.Assignee_Login_ID, StagingRequest.Resolution, null, StagingRequest.Cause_for_SLA_Violation, StagingRequest.SLA_Comments, StagingRequest.WorkLog_SupportDiary, StagingRequest.Work_Info_Notes, StagingRequest.Expiry_Date);
Analysis the the difference in group in Remedy. Some groups are differently customized in remedy while resolving the incidents

syntax error for ASP.NET onclick

I am modifying an asp.net page which has the following code:
<input type="button" id="room22SendEmail" name="room22SendEmail" value="Send" onclick="SendEmail('<%=mainValue%>');"/>
but there is an error after "SendMail('<%.." unterminated string constant. If I remove the single quotes I get a syntax error.
Whether it is
onclick="SendEmail(<%=#mainValue%>");'>
or
onclick="SendEmail(<%=mainValue%>");'>
I get the syntax error in the same places, marking the ( and )

How to determine css's class with if statement

<div class="<%#((int)Eval("Cevaplanma_Sayisi")>0) ? "divcevaplanmasayisiozel" : "divcevaplanmasayisinormal" %>">
my code is above.the code runs when I use access database but it doesnt run with sqlserver2008 where is the error.it says when I runs the code invalid exception handled
Try this:
<div class='<%#(((int)Eval("Cevaplanma_Sayisi"))>0) ? "divcevaplanmasayisiozel" : "divcevaplanmasayisinormal" %>'>
The first problem is that you need to convert the object value of "Cevaplanma_Sayisi" into int.
The second problem is that you must wrap the Eval statement within ' and ', otherwise you get malformed html.

Spring usage of typeMismatch messages

I have done some searches on the web and in stackoverflow to see how to handle the following message that I get on one of my screens:
Failed to convert property value of
type [java.lang.String] to required
type [java.lang.Long] for property
'qtyToShip'; nested exception is
java.lang.IllegalArgumentException:
Could not parse number: Unparseable
number: "a"
From research and from looking at the web I assumed that adding the following to my errors.properties file would produce the desired results:
typeMismatch.shippingCommand.qtyToShip=1. Invalid value for Qty To Ship, accepts only numbers.
typeMismatch.qtyToShip=2. Invalid value for Qty To Ship, accepts only numbers.
shippingCommand.qtyToShip=3. Invalid value for Qty To Ship, accepts only numbers.
qtyToShip=4. Invalid value for Qty To Ship, accepts only numbers.
typeMismatch.java.lang.NumberFormatException=5. Invalid value for {0}, accepts only numbers.
typeMismatch.java.lang.Integer=Must specify an integer value.
typeMismatch.java.lang.Long=Must specify an integer value.
typeMismatch.java.lang.Float=Must specify a decimal value.
typeMismatch.java.lang.Double=Must specify a decimal value.
typeMismatch.int=Invalid number entered
typeMismatch=Invalid type entered
I add integer values to the message to determine which one would show up.
Now at the top of my JSP I have the following:
<center>
<spring:hasBindErrors name="shippingCommand">
<c:if test="${errors.errorCount > 0 }">
<h4>Following errors need to be corrected:</h4>
<font color="red">
<c:forEach items="${errors.allErrors}" var="error">
<spring:message code="${error.code}" arguments="${err.arguments}" text="${error.defaultMessage}"/><br />
</c:forEach>
</font>
</c:if>
</spring:hasBindErrors>
</center>
The above is outside my Form, inside my Form I have the following (testing out ideals)
So the results is that when I run my code to trigger the error, I see that inside my form I get the following message:
1. Invalid value for Qty To Ship, accepts only numbers.
Which comes from this: typeMismatch.shippingCommand.qtyToShip
The outside of the form displayes:
Invalid type entered
What I do not understand is why am I able to display the correct message inside my form but not outside?
In the controller I have added the following:
#Override
protected void initBinder(HttpServletRequest pRequest, ServletRequestDataBinder pBinder) throws Exception
{
NumberFormat numberFormat = NumberFormat.getInstance();
pBinder.registerCustomEditor(Long.class, "qtyToShip", new CustomNumberEditor(Long.class, numberFormat, false));
}
Thanks
Perhaps error.code doesn't guarantee to return the most specific message code. Try to pass error message as a whole:
<spring:message message = "${error}" />

Peculiar error with ColdFusion on BlueDragon.NET

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.

Resources