i have had some problems to set my constraint messages. Aparently, grails have problem to bind the message. Whem i display the errors validations messages i receive:
Field error in object 'br.com.tokenlab.pemaap.IndividualPerson' on field 'alternativeDoc': rejected value [Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus purus non erat tempus dictum. Nunc cursus tellus sed fermentum laoreet. Pellentesque vel ante dapibus, ullamcorper nisl id, rutrum ante. Etiam ex libero, aliquam consectetur orci aliquam.]; codes [br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.error.br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.error.alternativeDoc,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.error.java.lang.String,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.error,individualPerson.alternativeDoc.size.error.br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc,individualPerson.alternativeDoc.size.error.alternativeDoc,individualPerson.alternativeDoc.size.error.java.lang.String,individualPerson.alternativeDoc.size.error,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.toobig.br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.toobig.alternativeDoc,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.toobig.java.lang.String,br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc.size.toobig,individualPerson.alternativeDoc.size.toobig.br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc,individualPerson.alternativeDoc.size.toobig.alternativeDoc,individualPerson.alternativeDoc.size.toobig.java.lang.String,individualPerson.alternativeDoc.size.toobig,size.toobig.br.com.tokenlab.pemaap.IndividualPerson.alternativeDoc,size.toobig.alternativeDoc,size.toobig.java.lang.String,size.toobig]; arguments [alternativeDoc,class br.com.tokenlab.pemaap.IndividualPerson,Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus purus non erat tempus dictum. Nunc cursus tellus sed fermentum laoreet. Pellentesque vel ante dapibus, ullamcorper nisl id, rutrum ante. Etiam ex libero, aliquam consectetur orci aliquam.,1,255]; default message [Property [{0}] of class [{1}] with value [{2}] does not fall within the valid size range from [{3}] to [{4}]]
Soo, a input the data to invoke this exception intentionality. My problem is replace this worst error message to another.
My domain constraints code:
static constraints = {
cpf unique: false, blank: true, nullable: true, size: 1..255
rg blank: true, nullable: true, size: 1..255
alternativeDoc blank: true, nullable: true, size: 1..255
nationalityType blank: true, nullable: true, inList: ["B", "E"]
photo blank: true, nullable: true
dateOfBirth blank: true, nullable: true
gender blank: true, nullable: true, inList: Holders.config.individualPerson.gender
nameOfFather size: 1..255
nameOfMother blank: true, nullable: true, size: 1..255
person blank: false, nullable: false
maritalStatus blank: true, nullable: true
race blank: true, nullable: true
cityOfBirth blank: true, nullable: true
countryOfBirth blank: true, nullable: true
}
And my messages.properties:
individualPerson.cpf.size.error=Número de caracaretes inválio para cpf.
individualPerson.cpf.blank=O cpf não pode estar em branco.
individualPerson.cpf.nullable=O cpf não pode estar em branco.
individualPerson.cpf.cpf=Cpf inválido.
not.cpf=Cpf inválido.
individualPerson.rg.size.error=Número de caracaretes inválio para rg.
individualPerson.alternativeDoc.size.error=O número do documento deve conter entre 1 á 255 caracteres.
individualPerson.nameOfFather.size.toobig=O nome para o Pai de conter de 1 á 255 caracteres.
individualPerson.nameOfFather.size.toosmall=O nome para o Pai de conter de 1 á 255 caracteres.
individualPerson.nameOfMother.size.error=O nome para a Mãe de conter de 1 á 255 caracteres.
individualPerson.person.displayName.error=O nome para exibição de possuir entre 1 e 255 caracteres.
person.name.size.error=O nome da pessoa de possuir entre 1 e 255 caracteres.
person.displayName.size.error=O nome para exibição de possuir entre 1 e 255 caracteres.
You set that field "alternativeDoc" have MAX SIZE 255. You try to insert more chars.
Related
I am having some issues with the textfield not moving up with the view.
I am using a textfield with Vertical axis (iOS 16) to create the multiline. This works correctly and stays above the keyboard as expected when it is not embedded in a scrollview. But as soon as the textfield is embedded in the scrollview the multiline just goes below the keyboard and you have to manually scroll to see the last line.
Please see code below. This should work correctly. But if you remove the scrollview you will notice the issue when typing.
struct ContentView: View {
#State private var text = "Lorem ipsum dolor sit amet. Nam voluptatem necessitatibus aut quis odio rem error repudiandae id aliquam perferendis et quidem quaerat et enim harum! Cum nesciunt animi rem quia vero aut omnis eligendi in ducimus eaque sit mollitia fugit est animi nesciunt. Ut exercitationem nulla qui dolor nihil ad autem vero quo internos sapiente eum dicta nihil qui exercitationem cumque et consectetur dolore. Et fugiat officiis non harum voluptas et modi repellendus ut repellat dolorem 33 eveniet quidem qui galisum veritatis. Id consequatur tenetur et eaque voluptas in assumenda delectus et fuga praesentium rem provident delectus est necessitatibus sunt quo dignissimos dolorum. Et reiciendis error et rerum eligendi qui illum error? In soluta ipsum est molestiae pariatur hic voluptas animi qui cupiditate amet."
var body: some View {
ScrollView {
VStack() {
TextField("Enter something", text: $text, axis: .vertical)
.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
}
}
If there are any GitHub repos you know that would also be great.
Update:
I have found a solution and will be posting it in the coming days.
This is not a definitive answer. In the simulator some buggy behavior appears. Try this out and see on a real device (that I don't have here).
import SwiftUI
struct ContentView: View {
#State private var text = "Lorem ipsum dolor sit amet. Nam voluptatem necessitatibus aut quis odio rem error repudiandae id aliquam perferendis et quidem quaerat et enim harum! Cum nesciunt animi rem quia vero aut omnis eligendi in ducimus eaque sit mollitia fugit est animi nesciunt. Ut exercitationem nulla qui dolor nihil ad autem vero quo internos sapiente eum dicta nihil qui exercitationem cumque et consectetur dolore. Et fugiat officiis non harum voluptas et modi repellendus ut repellat dolorem 33 eveniet quidem qui galisum veritatis. Id consequatur tenetur et eaque voluptas in assumenda delectus et fuga praesentium rem provident delectus est necessitatibus sunt quo dignissimos dolorum. Et reiciendis error et rerum eligendi qui illum error? In soluta ipsum est molestiae pariatur hic voluptas animi qui cupiditate amet."
#Namespace var bottomText
var body: some View {
ScrollViewReader { proxy in
ScrollView {
Text("Title")
.font(.largeTitle)
TextField("Enter something", text: $text, axis: .vertical)
.textFieldStyle(RoundedBorderTextFieldStyle())
.onChange(of: text) { newValue in
print("Fired.")
withAnimation {
proxy.scrollTo(bottomText, anchor: .center)
}
}
Color.red.frame(height: 50).id(bottomText)
}
}
}
}
When TextField axis is .vertical, anchor must be .top
VStack {
// ... other code
.onSubmit {
// update state here !!
if (i + 1) < inputsValues.count {
focusedInput = i + 1
} else {
focusedInput = nil
}
}
}
.onChange(of: focusedInput) {
// When TextField axis is .vertical, anchor must be .top
proxy.scrollTo($0, anchor: .top)
}
Here is full source code.
I am trying to add all elements to a list, Here is my code the code below will run in dart pad.
void main() {
mydates();
}
class Event {
const Event(this.date, this.title, this.description);
final DateTime date;
final String title;
final String description;
#override
String toString() => title;
}
List<Event> eventList = [
Event(DateTime(2021, 1, 1), "Buy milk",
"Lorem ipsum dolor sit amet, consectetur adipiscingelit. Pellentesque sem"),
Event(DateTime(2021, 1, 1), "Go to gym",
"Duis congue enim ut justo interdum, id porta turpisvarius"),
Event(DateTime(2021, 1, 2), "Running",
"Fusce in varius lorem. Praesent accumsan metus at semfaucibus"),
];
//Function
mydates() {
var eventDayMap = <DateTime, List<Event>>{};
for (var event in eventList) {
print(event.date); // Prints each element in the List<Event>
print(event.title);
print(event.description);
// Adding them to the eventDayMap
// Creates a new list
// Adds only the date and title
(eventDayMap[event.date] ??= []).add(event);
}
print(eventDayMap);
//print(eventDayMap.runtimeType);
return eventDayMap;
}
What is returned is this
{2021-01-01 00:00:00.000: [Buy milk, Go to gym], 2021-01-02 00:00:00.000: [Running]}
What I'm trying to achieve is the {date, title, description} and there can be many title and descriptions for one date.
{2021-01-01 00:00:00.000: [Buy milk, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sem ],
[Go to gym, Duis congue enim ut justo interdum, id porta turpis varius],
2021-01-02 00:00:00.000: [Running, Fusce in varius lorem. Praesent accumsan metus at sem faucibus]}
So I can have a title and a description returned.
Thanks for any guidance.
What your problem is depends on what your goal is.
If you want to create a valid JSON map, you will want to represent each element by a list. That doesn't appear to be the case since your keys are DateTime objects, not strings.
If you just want to be able to print the events, for debugging, then your problem is the String toString() => title; declaration.
Your map is fine, it maps from dates to Event objects. That's what you'll want.
Then you try to print that map, which calls toString on each value, which only returns the title string.
That only matters if you actually print the map, which you shouldn't be doing (except for debugging).
If you change toString to
String toString() => "[$title, $description]";
you'll likely get what it appears you're looking for.
I think I worked it out after a long time trying to do it my self it comes to me after posting it here.
I needed to return a List instead of a single event.
void main() {
mydates();
}
class Event {
const Event(this.date, this.title /*, this.description*/);
final DateTime date;
final List title;
//final String description;
//#override
//String toString() => title;
}
List<Event> eventList = [
Event(DateTime(2021, 1, 1), [
"Buy milk",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sem"
]),
Event(DateTime(2021, 1, 1), [
"Go to gym",
"Duis congue enim ut justo interdum, id porta turpis varius"
]),
Event(DateTime(2021, 1, 2), [
"Running",
"Fusce in varius lorem. Praesent accumsan metus at sem faucibus"
]),
];
//Function
mydates() {
var eventDayMap = <DateTime, List<Event>>{};
for (var event in eventList) {
print(event.date); // Prints each element in the List<Event>
print(event.title);
//print(event.description);
// Adding them to the eventDayMap
// Creates a new list
// Adds only the date and title
(eventDayMap[event.date] ??= []).add(event);
}
print(eventDayMap);
//print(eventDayMap.runtimeType);
return eventDayMap;
}
Now it returns
2021-01-01 00:00:00.000
[Buy milk, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sem]
2021-01-01 00:00:00.000
[Go to gym, Duis congue enim ut justo interdum, id porta turpis varius]
2021-01-02 00:00:00.000
[Running, Fusce in varius lorem. Praesent accumsan metus at sem faucibus]
Not exactly what I was looking for but it might be a better solution.
I am making a blog website in rails 5. But I wanted to create dynamic articles, where I can add headers, images and more. I discovered CKEditor. I have coded CKEditor into my form, <%= f.cktext_area :body, ckeditor: { language: 'en', uiColor: '#F0F0F0', toolbar: 'mini'} %> and it works great! It adds text to the body of my post, as I intended.
The only problem I have is that it is displaying in html format. The image below is a sample post I made. This is how I want my post to look after I submit.
And here is the problem. This is the exact result of the image above. When I save my post, this is what I see.
<p><span style="font-size:18px">A nice header</span></p>
<p>Lorem ipsum dolor sit amet, et eam lorem assum nihil, oportere erroribus mei no. At ius errem utamur, est nonumes consectetuer necessitatibus te. Cum et sumo nulla aliquid. Eos summo nihil no. Iusto inermis no qui.</p>
<p>Agam dicat mediocrem et vel, augue consulatu disputationi nam eu, vel id mentitum invidunt. Te assum accumsan nam, nam in recteque ullamcorper. Vix ei vitae labores legimus. Ea vis saepe meliore salutatus, usu an homero quaerendum disputationi. Eu menandri mediocritatem pri.</p>
<hr />
<p><img alt="" src="https://static01.nyt.com/images/2016/07/23/us/politics/23fd-campaign/23fd-campaign-master768.jpg" style="height:512px; width:768px" /></p>
<hr />
<p>Vim minim nonumy et, quodsi pertinax at pro, eu audiam facilisi cotidieque vel. Ius no quis probatus, ad eam equidem repudiare vulputate, no eos ponderum incorrupte. Cu delenit torquatos cum, at aperiam vocibus sit. Nec euismod incorrupte et.</p>
<p>Sit et molestie insolens oportere, dicam laudem no mel, et soleat vituperatoribus ius. In vix justo doming admodum, duo choro verear utamur an. Qui ut fugit atomorum, duo agam virtute et. Eam te nobis aliquando instructior, vix ancillae accusamus no. Nisl lucilius percipitur at pri, duo ne probo salutandi conceptam. Sed magna iudicabit forensibus ex, sed ne maiorum neglegentur.</p>
<p>Eu vix vidit convenire, pro id lorem aliquid quaerendum. Enim lobortis no mei, labore putant delectus et qui, ad solum petentium interesset nam. Pro virtute utroque debitis et, mei eu case blandit omittantur, id sed graecis abhorreant. Sed inimicus consequat id, choro commune ad cum, per dicat laudem phaedrum te.</p>
How can I get CKEditor to produce posts that look like the one in the image.
try using <%= raw(object.body)%>
What works:
In Breeze I can execute this query:
Q1
breeze.EntityQuery.from('accounts').where('id', 'eq', account_id)
which results in this request:
R1
http://localhost:8000/odata/findash.svc/accounts
?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'
which returns the correct data except that the transactions property looks like this:
transactions: {
__deferred: {
uri: "http://localhost:8000/odata/findash.svc/accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions"
}
}
I tried hitting the URI at transactions.__deferred.uri in a browser
R1.1
http://localhost:8000/odata/findash.svc/
accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions
and it does respond with the transactions I would expect.
What doesn't work:
To try and get that transaction list through Breeze I alter the above query with an expand clause like so:
Q2
breeze.EntityQuery.from('accounts')
.where('id', 'eq', account_id).expand('transactions')
which results in this request:
R2
http://localhost:8000/odata/findash.svc/accounts
?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'&$expand=transactions
which generates a 500 error.
I also tried this Breeze query:
Q3
breeze.EntityQuery.from('transactions')
.expand('account').where('account.id', 'eq', account_id)
which also generates a 500 error.
What I need to know:
I'm trying to rule out Breeze before I dive into the OData service which is built on Node+MongoDB+JayData.
The only difference between R1 and R2 above is the addition of &$expand=transactions. R1 works and R2 results in a 500 error. If R2 is a valid OData request then I need to focus my troubleshooting efforts on my JayData implimentation. The trouble for me is that I'm new to Breeze, OData & JayData, so I'm having trouble narrowing my search.
For reference, my JayData context.js is here:
$data.Class.define("$findash.Types.Account", $data.Entity, null, {
id: { type: "id", key: true, computed: true },
name: { type: "string" },
status: { type: "string" },
notes: { type: "string" },
transactions: { type: "Array", elementType: "$findash.Types.Transaction", inverseProperty: "account" }
}, null);
$data.Class.define("$findash.Types.Transaction", $data.Entity, null, {
id: { type: "id", key: true, computed: true },
account: { type: "$findash.Types.Account", inverseProperty: "transactions" },
payee: { type: "string" },
memo: { type: "string" },
amount: { type: "int" }
}, null);
$data.Class.define("$findash.Types.FinanceContext", $data.EntityContext, null, {
accounts: { type: $data.EntitySet, elementType: $findash.Types.Account },
transactions: { type: $data.EntitySet, elementType: $findash.Types.Transaction }
}, null);
$findash.Types.FinanceContext.generateTestData = function (context, callBack) {
context.accounts.add(new $findash.Types.Account({
name: 'Checking',
status: 'Active',
notes: '<p>Notes lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mauris quam, elementum in tincidunt id, mollis eget urna. Nulla fermentum est id risus venenatis malesuada. Quisque sed ipsum at nisl malesuada dictum vitae nec libero.</p><p>Aenean consectetur, purus eu semper feugiat, purus lacus semper nibh, at luctus ipsum metus non justo. Donec justo mi, rutrum a scelerisque sed, feugiat vel quam. Etiam justo nisi, vehicula ac congue vitae, ultricies non quam. Aliquam a velit in mauris luctus elementum. Praesent sollicitudin quam mattis velit sodales vitae feugiat felis volutpat.</p>',
transactions: [
new $findash.Types.Transaction({
payee: 'Shell Gas',
memo: 'Checkcard Transaction',
amount: -3500
}),
new $findash.Types.Transaction({
payee: 'Kroger',
memo: 'Checkcard Transaction',
amount: -9000
}),
new $findash.Types.Transaction({
payee: 'Papa Murphy\'s',
memo: 'Checkcard Transaction',
amount: -1500
})
]
}));
context.accounts.add(new $findash.Types.Account({
name: 'Savings'
}));
context.accounts.add(new $findash.Types.Account({
name: 'Power Company'
}));
context.accounts.add(new $findash.Types.Account({
name: 'Gas Company'
}));
context.accounts.add(new $findash.Types.Account({
name: 'Cable Company'
}));
context.accounts.add(new $findash.Types.Account({
name: 'Water Company'
}));
context.accounts.add(new $findash.Types.Account({
name: 'Trash Service'
}));
context.saveChanges(function (count) {
if (callBack) {
callBack(count);
}
});
};
module.exports = exports = $findash.Types.FinanceContext;
Can you post the code for the relevant sections of the server side model? This looks like a problem on the server side with the model definition, or how it is exposed thru OData.
The real test of this is to try hitting the OData service without Breeze involved at all. I'm guessing that you will get the same error. If not, then this is a Breeze error. If so, then you need to review your OData service.
I am working on my PHP file and now I get this message.
"Parse error: syntax error, unexpected '<', expecting T_FUNCTION in /home/content/18/9029618/html/wp-content/themes/NewBusiness/includes/aboutus.php on line 8"
Have no idea what is wrong and now my site is down. Here is the code below.
<?php
new Themater_AboutUs();
class Themater_AboutUs
{
var $theme;
var $defaults = array(
'enabled' => 'true',
'hook' => 'main_before',
'title' => 'Welcome to our website. Neque porro quisquam est qui dolorem ipsum dolor.',
'image' => 'about-image.jpg',
'content' => 'Lorem ipsum eu usu assum liberavisse, ut munere praesent complectitur mea. Sit an option maiorum principes. Ne per probo magna idque, est veniam exerci appareat no. Sit at amet propriae intellegebat, natum iusto forensibus duo ut. Pro hinc aperiri fabulas ut, probo tractatos euripidis an vis, ignota oblique. <br /> <br />Ad ius munere soluta deterruisset, quot veri id vim, te vel bonorum ornatus persequeris. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.'
);
function Themater_AboutUs()
{
global $theme;
$this->theme = $theme;
if(is_array($this->theme->options['plugins_options']['aboutus']) ) {
$this->defaults = array_merge($this->defaults, $this->theme->options['plugins_options']['aboutus']);
}
if($this->theme->display('aboutus_enabled') ) {
$this->theme->add_hook($this->defaults['hook'], array(&$this, 'display_aboutus'));
}
if($this->theme->is_admin_user()) {
$this->aboutus_options();
}
}
function display_aboutus()
{
if(is_home()) {
?><div class="span-24 aboutusbox">
<?php
if($this->theme->display('aboutus_image')) {
echo '<img class="aboutusbox-image" src="' . $this->theme->get_option('aboutus_image') . '" />';
}
if($this->theme->display('aboutus_title')) {
echo '<h2 class="aboutusbox-title">' . $this->theme->get_option('aboutus_title') . '</h2>';
}
if($this->theme->display('aboutus_content')) {
echo '<div class="aboutusbox-content">' . $this->theme->get_option('aboutus_content') . '</div>';
}
?></div><?php
}
}
function aboutus_options()
{
$this->theme->admin_option(array('About Us', 14),
'"About Us" section enabled?', 'aboutus_enabled',
'checkbox', $this->defaults['enabled'],
array('display'=>'inline')
);
$this->theme->admin_option('About Us',
'Title', 'aboutus_title',
'text', $this->defaults['title']
);
$this->theme->admin_option('About Us',
'Image', 'aboutus_image',
'imageupload', get_bloginfo('template_directory') . "/images/" . $this->defaults['image'],
array('help' => "Enter the full url. Leave it blank if you don't want to use an image.")
);
$this->theme->admin_option('About Us',
'Content', 'aboutus_content',
'textarea', $this->defaults['content'],
array('style'=>'height: 250px;')
);
}
}
?>
Is that the full file? Is there a <?php at the beginning?
The sample that you have pasted is missing a closing brace } at the end.