Tuesday, May 8, 2012

customize jsf validator msg

i have the following in my messages.properties file:



javax.faces.component.UIInput.REQUIRED=Please enter a value for {0}
javax.faces.validator.LengthValidator.MINIMUM = At least {0} characters are required for {1}
javax.faces.validator.LengthValidator.MAXIMUM = At most {0} characters are required for {1}



when error occurs, i got these outputs:



At most 8 characters are required for pwd At most 8 characters are required for pwd
At least 6 characters are required for pwd At least 6 characters are required for pwd



as it shows, it repeats, how can I change the msg that just appear once?





dojo 1.6 DataGrid cannot display lists?

In dojo 1.7.2, if I create a data store containing array values, dojox.grid.DataGrid displays them with no problem, separating each item with a coma.



However, in dojo 1.6, it takes only the first element of my array. I have a project where I have to use version 1.6. Is there any workaround for this in that version ?



To illustrate the problem, here are 2 examples :





Thanks !





How do I call native windows APIs from managed c# code?

I want to use the following native APIs:



NtOpenProcess 
NtOpenThread
NtReadVirtualMemory
NtWriteVirtualMemory
PsCreateSystemThread
KiAttachProcess


Is it possible to call these APIs from managed C# code? If so, can someone provide an example of how this would be done?





PHP getting full image attribute

I am fetching url like facebook. For all images in that page I get them with



$src = $tag->getAttribute('src');


it works fine if the foreign site put a full webpath to their images. But sometimes they use relative path only and that returns a broken image.



Since I have the full url, is there a way to check if $src contains http:// or https?



if not then I could do



$src = $link . '/' . $src; 


for those relative images. I tried, they display. But if they already had it, then they will not display as path then contains double url.





Why can't I replace the __str__ method of a Python object with another function?

Here is the code:



class Dummy(object):
def __init__(self, v):
self.ticker = v


def main():
def _assign_custom_str(x):
def _show_ticker(t):
return t.ticker
x.__str__ = _show_ticker
x.__repr__ = _show_ticker
return x


a = [Dummy(1), Dummy(2)]

a1 = [_assign_custom_str(t) for t in a]
print a1[1]
# print a1[1].__str__ # test to if orig __str__ is replaced


I was hoping to see the output like this



2


However, instead I see the standard representation:



<__main__.Dummy object at 0x01237730>


Why?





Summing Large Numbers

I have being doing some problems on the Project Euler website and have come across a problem. The Question asks,"Work out the first ten digits of the sum of the following one-hundred 50-digit numbers." I am guessing there is some mathematical way to solve this but I was just wondering how numbers this big are summed? I store the number as a string and convert each digit to a long but the number is so large that the sum does not work.



Is there a way to hold very large numbers as a variable (that is not a string)? I do not want the code to the problem as I want to solve that for myself.



Thanks.





XCode does not let me change the code

I have been working on a project and since last week xcode does not let me make any changes in my xib file and another page in the project. However I can make changes in other pages. When I open it as root I can make changes in main.xib as well. What can cause this? It is very annoying.



This is what I get:



"MainWindow.xib" is locked for editing and you may not be able to save your changes. Do you want to unlock it?