Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!

Henrique Sousa

Ranch Hand
+ Follow
since Apr 29, 2004
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Henrique Sousa

Originally posted by Vlado Zajac:
This is what the variable reading does.

I don't know what is the intended purpose of that variable, but the code sets it to true during first read and after that all other reads are not counted because it is set to true.



Now that was stupid... I forgot to set that variable back to false. I did that because I assumed some read method might end up calling another one (like read(byte[]) calling read(byte[],int,int)) and I would have the wrong byte read count. Thank you so much!
14 years ago
Hi, ranchers!
I am trying to track how many bytes are actually read from a remote zip file, but a mistery lies before me. Here is the scenario: I have URLConnection to a zip file from which I obtain an InputStream. I create a ZipInputStream from that. In order to audit the reads I wrap the InputStream (the one from the URLConnection) into a my own class, AuditInputStream. Its code is below.
The strange is that, no matter which files I extract from the zip file, the Audit always says only one call was made to read(byte[], int, int) and it returned 30 bytes; but the zip file is 260KB long! So where is the Zip stream reading from?


Any help is appreciated.

Henrique
14 years ago
Hi, I have the same problem. However my converter is declared in faces-config.xml, and I refer to it with converter="myConverterID" (no surrounding '#{}'). getAsString() is called, but not getAsObject. I'm using MyFaces embedded with JBoss 4.0.4.GA. Did you solve this?
14 years ago
JSF
Hello
I'm building a custom component (my very first), but I seem to have some problem with it. There is a parent component and nested children. The parent seems fine, it is supposed to output some HTML for itself in encodeBegin(). Then it should render code for its children in encodeEnd(). The children encodeBegin() and encodeEnd() methods are called, but no HTML is rendered for them. Here is what the code looks like (just the UIComponents):

I've not qutoed the implementation of other methods, I am guessing they are not relevant. Now, all these are called but only the parent code is rendered correctly. Since I am a newbie at custom components, I am sure to be doing something very wrong; I just don't know what. Any hints?
14 years ago
JSF
It is more a matter of naming, i think. You see, the request is nothing more than a bunch of parameters. I dare to call it a java.util.Map<String,String>. The framework maps parameters to properties, so you could state, from the framework user point of view, that the properties are persistent across requests.
Now, the properties must exist in some instance, so it is created if its scope is set to request. Why not persist it accross requests? Simply put, because Map<String,String> does not support Object. You can use a converter to create a String representation of your object and "persist" it acrross requests.
So this is just a matter of passing Strings, not objects. I hope this is clear enough to be understandable.
[ June 09, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF
It seems everything is right. After all, year 198 is valid. I don't remember what happened then, but it certainly is part of planet Earth's history. On the other hand, month 13 does not exist in our gregorian calendar. You see, the problem is not about the correctness of the date itself, but the correctness of its meaning. So you need validation for that date, perhaps by implementing a javax.faces.validator.Validator; at least that is my suggestion. Good luck
14 years ago
JSF
I don't know if I got it... you mean to say that you have an object which has a property that holds an e-mail address and you want to create a mailto: link for this address? If that's the case, you can use some EL:

This will create a field with the current value of the user's e-mail (so you can change it) and a link beside it which you can click and the default mail application will be opened with a new message for that recipient. Does this cover what you want to know?
[ June 07, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF
All right, I tried dark magic (PhaseListener) approach. I created a PhaseListener and registered it for the RENDER_RESPONSE phase. This way I could get to the UIComponents before the JSP is rendered again, right? Apparently not. I disabled the fields in both beforePhase and afterPhase methods and nothing happened in the page. I am going to try the ultimate evil, Javascript, in order to keep this maintainable at some level.
Man, JSF is good but it can be such a pain sometimes
[ June 07, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF
Wow! Now I sense some dark magic going on -- and I like it
Indeed, the managed bean is in request scope; but by the time the ActionListener is invoked isn't the request already rebuilt? I mean, is the request that is available at the ActionListener the same available for the action and the jsp page?
What about that phase listener? I think I am going to check that out first.
[ June 07, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF
The problem is that it is just not working the way I did. I don't want to bind every disabled property because that would take maintaining over a thousand fields in dozens of pages. It is a lot better than binding the field, of course.
Could it be MyFaces' erroneous behavior?
14 years ago
JSF
Hi, everyone!
I am trying to create a sort of filter to make pages read-only under some circumstances. So I created an ActionListener for this. Everything seems to work: the listener is called, it takes all of the current UIViewRoot's children and sets the disabled property to true wherever it can be done. But when the page is rendered again the components (inputText, selectManyCheckbox and so on) are not disabled.
Maybe I thought wrong, maybe I just cannot do this sort of thing in the ActionListener. If so, how can I do it? Binding a quarter of my application's buttons does not seem feasible. Suggestions?
14 years ago
JSF
Hello, ranchers!
As I read the spec for some clarification I found this:

3.5.6 - Exceptions
Lifecycle callback methods may throw runtime exceptions. A runtime exception thrown by a callback method that executes within a transaction causes that transaction to be rolled back. No further lifecycle callback methods will be invoked after a runtime exception is thrown.


The question is: does this implies that PostUpdate and PostPersist callbacks will be contained in the active transaction (if any)? Or is it anywhere else explicitly stated?

[ May 29, 2006: Message edited by: Henrique Sousa ]
[ May 29, 2006: Message edited by: Henrique Sousa ]
All right, I added the name and id attributes (in all combinations) and... nothing changed, sorry. By the way, I am running under JBoss 4.0.4 CR2 -- it contains MyFaces implementation version 1.1.1. Did anyone ever make this work with this library and version? Code samples?

Updating: when I added the id attribute to outputText and outputFormat the HTML code changed, as expected, to:

[ May 16, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF
Hi, guys
Today I have a rather annoying problem with a JSF tag. I am trying to format a date (which is actually an instance of java.sql.Timestamp) into text. Now, documentation says it works just like java.text.MessageFormat.format(String,Object[]), so I tried this:

Amazingly, this outputs "null". My first assumption was that I had used outputFormat wrongly, so I tried just outputText. Then I did just the expression and put all together:

This generated the following output:

The two first blank lines and "null" are the outputFormat. Then we have a blank for the outputText and valid values for the JSP expressions. I tested MessageFormat.format method and it only returns null if the parameter is an array with a null reference in the first position. I tried changing pattern to "dd/MM/yyyy HH:mm", but it was printed literally. Did I do anything wrong?
[ May 16, 2006: Message edited by: Henrique Sousa ]
14 years ago
JSF

In the case of JBoss 4 it is Tomcat 5 it ships with (I don't think it has shipped with v4.0 since version 2.something).


If I am not mistaken, JBoss was shipped with Tomcat 4 up to 3.2.1 or 3.2.3. Version 3.2.4 most certainly is shipped with Tomcat 5
14 years ago