I am creating a school management application using Oracle ADF. I have one Student Result page where we can add the result for each student. Here is the image of the same:
Student's Result Page
When I change say the Result Year, I get an exception like:
<oracle.adf.view> <_logUnhandledException> <ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase UPDATE_MODEL_VALUES 4>
oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:java.lang.Integer from type:java.lang.String with value:Pass
Don't Understand this only the student id is number, all other 3 attributes are string only.
Can anyone help?
Below is the Jsff Code:
<af:column sortProperty="#{bindings.ResultStudentResultView.hints.ResultYear.name}"
filterable="true" sortable="true"
headerText="#{bindings.ResultStudentResultView.hints.ResultYear.label}"
id="c7">
<af:selectOneChoice value="#{row.bindings.ResultYear.inputValue}"
label="#{row.bindings.ResultYear.label}"
required="#{bindings.ResultStudentResultView.hints.ResultYear.mandatory}"
shortDesc="#{bindings.ResultStudentResultView.hints.ResultYear.tooltip}"
id="soc2">
<f:selectItems value="#{row.bindings.ResultYear.items}" id="si2"/>
<f:validator binding="#{row.bindings.ResultYear.validator}"/>
</af:selectOneChoice>
</af:column>
This error is with the column Result, check what is the attribute type in view object and if corresponding default value is given as literal.
Related
when i duplicate a sale order or account invoice qweb report from the report created by other user, the information about saleperson is the same with the orginal report. Could we get the current user in the copy one. Please help me to point out step by step the right way to get the purpose. Thank for your time. Sory because my low level of English.
There are 3 different way we can add and print the user detail into the Qweb Report
1. Directly access the 'user' global object in qweb Part
<span t-esc="user.name" />
2. Get the current user detail from the report parser class
parser report class method:-
def get_cur_user(self):
return self.pool.get('res.users').browse(self.cr,self.uid,self.uid).name
Call parser class method into qweb View Part :-
<t t-if="get_cur_user()">
<spane t-esc="get_cur_user()" />
</t>
3. Set the custom user_id (many2one) field on that particular report and set as default attribute as env user record set
Add into your report model :-
user_id = fields.Many2one('res.users', string='Print By User', default=lambda self: self.env.user)
Access that field into the Qweb View part:-
<t t-if="o.user_id">
<spane t-field="o.user_id.name" />
</t>
I am using inList constraint to validate list of values. And I am not using directly command/domain class to show error message
ex:
name inList: ["Joe", "Fred", "Bob"]
if name is not from the list error message is shown as
Property [{0}] of class [{1}] with value [{2}] is not contained within
the list [{3}]
Instead i want to show a proper message having values as Property of name of class MyClass with value XYZ is not contained within the list Joe, Fred, Bob.
Whereas MyClass , XYZ and List values must be coming from cmd object that I use to validate.
Please help on how to show this message.
I got the solution for it.
I can get the rejected value from cmd.errors.getRejectedValue() and I can get list of values from cmd.constraints.name.inList
We have a 1-to-many relationship between a parent Object A and Children B (Contribution) . A field in the child object depends on a specific selection of a field in the parent object. The save of the parent is a cascade so all the validation messages for both the parent and the child occur at the same time.
There is no usable differentiation between the multiple child objects when the validation error occurs (ie there is no name. We could use the ID but the user does not want to see the ID in the UI so it would be pointless). How can I remove duplicate error messages of the children or make it a set so only 1 message of a certain type shows?
Object A
InitiativeType initiative
static hasMany = [ contributions: Contribution ]
Contribution
SpecialCategory specialCategory
static constraints = {
specialCategory nullable: true, validator: { val, obj ->
if ((val && val.id > 53 && val.id < 75) && !obj.A.initiative?.contains(5) ) { // special initiative
return ['specialValidation']
}
}
Certain IDs in SpecialCategory will only be valid if a certain Initiative ID is selected. Otherwise, throw the validation error stating "Special Category [ID] requires you to select Initiative [Required_Initiative_Name]"
As it stands, it is possible to see the same error message multiple times if a user creates multiple Contributions that use the same SpecialCategory ID and not having selected the appropriate Initiative. Can the validation messages be a set? Or do I have to loop through all the errors and attempt to remove the dupes (gross)?
There are better ways to handle this (such as not showing the certain SpecialCategories in the select when the Specific Initiative isn't selected) but this is what the user group requested. I'm currently on pushing on doing it a more correct way.
I had to break up my error output block in my GSP. This seems to work fine:
<g:eachError var="err" bean="${A}">
<g:if test="${err.code != 'specialValidation'}"> <!-- show message later to remove duplicates -->
<g:message error="${err}" /><br />
</g:if>
</g:eachError>
<g:if test="${A?.contributions?.errors?.size == 1}">
A Contribution with a Special Category must also include the Special Initiative.
</g:if><g:elseif test="${A?.contributions?.errors?.size > 1}">
Contributions with a Special Category must also include the Special Initiative. There are currently ${a?.contributions?.errors?.size} in error.
</g:elseif>
I have an Invoice
class Invoice{
static hasMany = [lineItems: InvoiceItem]
double total
}
class InvoiceItem{
String description
double price
double qty
}
My issue is with form validation. If a user enters a string or invalid number format in either price or qty I get a
Failed to convert property value of type java.lang.String
to required type double for property price
BUT the error is in the Invoice object NOT in the LineItems object therefore I cannot highlight in RED the form appropriately. (And field value remains at zero when displayed so message is somewhat meaningless to user)
I was thinking of using COMMAND object with String parameters and validating their numeric value but I can't figure how to bind the InvoiceItem List.
What is the appropriate Grails way?
I could do all validation on the client side in javascript but that is not my question
You can do it with command objects. You need to read:
http://blog.peterdelahunty.com/2009/01/cool-way-to-dynamically-add-entries-to.html
command object data binding
Grails command object data binding
http://grails.1312388.n4.nabble.com/validating-nested-command-objects-td1346994.html
I have a list of resources that have managers which are also resources in my system. I want to sort the list of resource by their names. What I am finding is that Grails is sorting the list by the resource Id and not the field that I am specifying.
<g:sortableColumn property="orgRole" title="Org Role" />
<g:each in="${resourceInstanceList}" status="i" var="resourceInstance">
<td>${fieldValue(bean: resourceInstance, field: "manager")}</td>
<!--<td> ${resourceInstance.manager.toString()} </td>-->
</g:each>
I have defined the static mapping on my resource to sort by my 'name' attribute and I have a toString method that I have tried calling that also returns the 'name' of the object as the value. Still seeing the list sorted by the Integer 'id' attribute that is tied to the sequence in the database.
The precision needs to be defined on the sortableColumn and not on the td. I should have used this:<g:sortableColumn property="orgRole.name" title="Org Role" /> this explicitly tells Grails which field I want to use, otherwise it relies on the default id element of the object.