Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

B Nirvan

Ranch Hand
+ Follow
since Oct 20, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by B Nirvan

Hi,
I have a h:selectOneMenu which works well on IE 8 and Google chrome. Recently, I tested the code on IE 9 and the h:selectOneMenu is breaking up. Here is the code for the h:selectOneMenu tag that I am using.


The f:ajax tag inside h:selectOneMenu is supposed to refresh cityList, areaList but that doesn't happen. Instead these selectOneMenu lists retain their old values.

I am using Mojarra 2.0.2 with netbeans and glassfish server 3.

regards,
Nirvan.
9 years ago
JSF

kajel rani wrote:i want to validate that entered string is not null and its size is within the specified range defined in annotations.



Use a validator

regards,
Nirvan.
9 years ago
JSF
Change action="employee.deleteEmployee" to action="#{employee.deleteEmployee}"

regards,
Nirvan.
9 years ago
JSF

Grae Cullen wrote:Hi all,

Basically, my problem is that if the user click the one button, and does wait for the page to respond, and then clicks another button, it seems like there is a race condition.

How can I avoid the code for the first button press using the same variables as the code for the second button press?

I suspect that both requests are going to call the the same getters and setters in some random order, because each button click will be in a different phase of the JSF model.


Ok, here is an example, suppose the user clicks a button, the action function changes some variable. That variable is linked with a getter and a setter to an actuall jsf tag. Now suppose the action function is 50% complete. Now the user hits the same button. JSf will call the getters and the setters linked to that same variable, restoring the state or whatever. Basically, that variable is reset back to what it was before the action changed it.

Now the action function for the first click is continuing to run, and it changes that same variable again. Even with out the second action call, it is a race condition.



Disable the button after click using javascript

regards,
Nirvan
9 years ago
JSF
In JSF one way to do is create a List of SelectItems and point the value attribute of the f:SelectItems to that list. Here is sample code

<f:selectItems value="#{stateBean.stateList}"/>

stateList is a backing bean property defined as

List<SelectItem> stateList;

You can also bind the value directly to your List instead of using List<SelectItems>, but it seems you don't get to define different values for itemLabel and itemValue. I am not very sure about this approach though

regards,
Nirvan.
9 years ago
JSF
Dieter,
I am using the textArea to display some messages to the user. These messages come from a text file on the server . These messages have nothing to do with the user input. So I believe, that it wouldn't cause problems related to cross-site scripting (although I don't know much about that term).

regards,
Nirvan
9 years ago
JSF

Dieter Quickfend wrote:



Dieter,
I never thought of using textArea that way. Thanks for that trick. I have implemented it.

regards,
Nirvan.
9 years ago
JSF
Dieter,
The textArea is inside the form, as I am populating it from backing bean. Making it disabled results in the content being greyed out and hence very difficult to read.

thanks and regards,
Nirvan.
9 years ago
JSF
I am using h:inputTextArea which is populated in the backing bean. The textArea is only for displaying data so I made it readOnly. The problem is that when the form is posted back, the textArea data also gets posted to the server (which I am trying to somehow avoid). The reason for avoiding posting of textArea data is that it is too large to be posted and given the default post size , "java.lang.IllegalStateException: Post too large" is thrown when the form is submitted.

How do I avoid posting of textArea data when the form is submitted?

regards,
Nirvan.
9 years ago
JSF
Tim,
Thanks for the explanation. The hosting provider will be hosting glassfish server on windows, so I guess we will have to mutually decide on the best place for the logs.

regards,
Nirvan.
9 years ago
JSF
Paul,
Perhaps I should I consulted the hosting provider before posting the question. Anyway, now that I am sure that log files shouldn't be placed in application jar, I have a fair idea what to negotiate. Thanks for the advice,

regards,
Nirvan.
9 years ago
JSF
I will be hosting a web application for a NPO on a third party hosting provider. I have to log some exceptions and some informational messages for asynchronous processing. Since the logging requirements are quite simple, I decided to go ahead with the java logging api. Now I am unsure as to where the log files should reside. I can't put them in my application's jar, since they will be erased when I redeploy my application for some reason (and some other reasons also). I don't think the hosting provider will provide access to any other real file path on his server. Can anyone provide me with some insight as to where the log files should normally be placed.

regards,
Nirvan.
9 years ago
JSF
Tim,
Basically I was trying to update the phones with the values entered by the user. First I thought it would be possible to simply remove all entries from the map and add the new entries. But as you said, it may require either a commit (which I cannot do since I am in middle of a transaction) or perhaps flush (which would mean additional database hit). So I changed the way I edit phones by simply locating the correct phone record from the phones map and updating its values. For that I used the simple code given below.

Surprisingly, the above code does not update values in the database ! Can it be a problem with hibernate, or is there some mistake in my code.

regards,
Nirvan.
Hi,
I have a classic one-to-many relation between Donor and his phones. I have mapped this using a java.util.Map as shown below.
In Phone entity

In Donor entity

The challenge I am facing is removing all the phones(many side) of the donor(one side). The code I was expecting to work is given below.

After executing the above removal code, if I again try to add an phone to the donor, I am getting a ConstraintViolationException which means that the removal code didn't work. Any ideas why the phones are not being removed from the relationship. If someone can provide a better implementation I would be very grateful.

regards,
Nirvan.
Macro,
Killing the glassfish process worked for me. That was indeed a very quick fix. Thanks a lot.

regards,
Nirvan.
9 years ago