nimo frey

Ranch Hand
+ Follow
since Jun 28, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by nimo frey

Does anyone know the difference of



and that:



Which one should I prefer?
11 years ago
Hello both,

sorry sorry. I was so blind! Yes, you are absolutely right.

It is if you make that a field of the object.



I like JV’s suggestion of an automatically incremented field.



I was lost in fussiness;) (Serializable objects and so on..). But now it is clear!

Thank you for your patient!

11 years ago
I guess, I dont want to use the identityHashCode.

It is better to use a real unique id. However, I do not persist the entity in a database, so I am not able to use a database-id-field.

I guess, I cannot use the

UUID a = UUID.randomUUID();

When I generate a UUID for the instance x and the client sends that UUID back to me, the instance x is no more binded to that UUID.
So I cannot compare it with the servers UUID as generating a new one for the instance x results in another UUID. I cannot use a singleton-class or the like.


Maybe, this is the right thing to do:
UUID b = UUID.fromString(this.toString());

I dont know.

However, I guess, the best is to use override the toString()-Method of my Object and use the String as a Identifier.

Both, Thanks for your help!
11 years ago
Oh, actually I have no collisions - all my instances are identifiable via the string version of the hashCode.

So what should I use instead? Should I override the toString-Version for identification?

So I do not use this '1448505687' but use the string-version "hobbies: soccer|name: paul|age:22|state:null". Is this better?
11 years ago
1) I know. I wrote my hashCode/equals-Method with these methods.

2) I am generating the hashCode of an instance and cast it to a string X. This string, I gave it to the client (for example: web-view). When client sends the X to me, I can look, what object it is by using String.valueOf(_o.hashCode).equals(X).

As I stated before: The client has no java-object, so I cannot use _o.equals(X), because X is not a Java-Object, it is a string-identification of the java-object.

The only question I have is:

Should I use a toString-Method of the instance or can I rely on the computed hashCode (which is also unique) to identify my object-instance from the client to the server.

Actually it works without failure, but I am not sure, if I made it totally right.
11 years ago
I use the Objects.hash and Objects.equals-Methods of Java7 to override hash/equals-Method. All works fine.

I have this question:

Can I use the hashCode of an instance for temporarly identification or should I use a string-version (by overriding toString) to identify this object.

For example:

The instance a of type O is represented by the hashCode '1448505687' and this string-version "hobbies: soccer|name: paul|age:22|state:null".

I have a list of O's and want to look, if the list contains the "instance a", which I get it from the client.
The client has either the hashCode or the string-version of the instance!
So I get only the hashCode or the string-version of "instance a".

Which version should I use:

// client gives me the instance a in form of the hashCode


// client gives me the instance a in form of an identifiable string-version of a:


So which version should I use? Both actually works, but I am not sure, if I can rely on the hashCode everytime. Which is better?
11 years ago
Oh, so should I do something like that:




Is this better ?
Thanks it works, but I how do I solve that, when using module-pattern:



I want to call Submodule by string:

Something like

does not work.
I have a common js-object:



I know, I can call property a via or via .

I want to do something like this:



But it does not work. How can I do that? Should I use eval or call() or something?
I was so blind! You are right!

I am using jsf with templating and had something like this <ui:remove>

within the tags which was called by javascript.

So that was the reason.

Thanks !!
I have a self invoking function with a window.onload in it. But the window.onload is not really called after windows is loaded. Often, myBtn returns null as the chrome-debugger says

"Uncaught TypeError: Cannot set property 'onclick' of null".

Why is that so? How can I solve that?





Using jquery and this script returns the same error:






I have put the script into the head-element.

I know, that document.ready will run immediately after DOM is built.
Self-invoking functions will run instantly - but window-onload should, normally should run after dom is built.
But this is not the case. Why?
I added the parent-property (the string-identifier of the parent component in which my component is put):



The use of my component:




now returns the following error:

java.lang.IllegalArgumentException: java.lang.ClassCastException@2b4193b3
at sun.reflect.GeneratedMethodAccessor213.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:2399)
at javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:2283)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler$CompositeComponentRule$LiteralAttributeMetadata.applyMetadata(CompositeComponentTagHandler.java:577)
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
12 years ago
JSF
Unfortunately, ":client-view" does also not work:

<f:ajax> contains an unknown id ':client-view' - cannot locate it in the context of the component test-id.

When I look at the client-code, that the component has indeed the "client-view" as ID. (no ":my-form:client-view", as I wrapped the component with <h:form id="my-form" prependId="false">).

Why does my JSF-component not find the ID of its parent?
12 years ago
JSF
I want to organize/structure/encapsulate all my jquery javascript code:

I have a file "mypage_version1.js" with the following content (VERSION 1):



How can I organize it better?

Does the file "mypage_version2.js" with the following content (VERSION 2) structures the code better than "VERSION 1"?:



I am in doubt, which version is better (both works).

Version 1 is shorter, but cluttered within the file.

What is best practice?

I have a component called "test":



and the "view.xhtml" which uses the component "test":




When rendering "view.xhtml", then I get the following error:




How can I solve that?

(Besides, when using <f:ajax render="@form" /> within the component-component all works, but I want to assign a ID to limit the rendering.)

12 years ago
JSF