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?





Xcode Project Icon files and Organiser Archives artwork

I have all my icon files set up in my project and they are found alongside the .xcodeproj file on my Mac, and I have added them to the plist file as per the screenshot, when I build there are no warnings, but when I Archive, I get 4 warnings which I don't understand.



I found no documentation about the new "Icon file (iOS 5)" and if I should be mirroring the "Icon files" property, I tried with and without it and I still have these warnings. It's worrying because the warning explanation says it's unable to validate my application. I'm worrying about Apple submission.



If I remove this files from the plist then there is no warning, and testing on iPad and iPhone devices, the icons for settings and spotlight still work fine it seems, so these files are being used.



However the Apple docs do tell you to add references to these files in your plist.



Does the location of these files have any impact on if they're being used or not ? I would like to remove them from the root directory and into an "Artwork" directory but I can see that this now removes the preview from the Target summary.



Also in the Archive section of the Organiser I used to get the iTunesArtwork to appear - now my Icon.png is blown up and consequently very ugly. I wonder if this suggests I am doing something wrong ?



There is no clear guide to how I should treat these icons...



enter image description here



enter image description here



UPDATE



It seems like for these warnings to be avoided, you must have a folder named "Resources" in the root of your project. And import that folder into the Xcode, you still must declare in the plist, two times these icon files.
I still don't know how to get my iTunesArtwork to be used in the Organizer's Archive view.





dynamic pivot with join

I have 2 tables.
Table1



Id  MonthlySalaryXId    SalaryComponentXId  ComponentValue
1973 158 216 0
1974 158 217 0
1975 158 213 50000
1976 158 214 30000
1977 158 215 6000


and table2



Id  Component   SalaryComponentTypeXId
213 basic pay 3
214 HRA 3
215 pf 4
216 bonus 1
217 Incentive 1


I want to get the component from table2 as dynamic entry and for each component i need to get componentvalue table1
Example like this



Basic    HRA        PF     
50000 30000 6000


Please help me to do this work. I am in trouble in not completing this. Please help me.
Please anyone help me to solve this.





tree for ChilNode of childNode in javascript

i have this simple html:



<div id="tree">
<div class="roi">
<ul>
<li>text1</li>
<li>text2</li>
<li>text3
<ul>
<li>insideText1<li>
<li>insideText2<li>
</ul>
</li>
</ul>
</div>
</div>


i want to get only the item "text2" and the item "insideText2";
so i tried to wrote:



var Tree=document.getElementById("tree").document.getElementsByTagName("UL");



But i do'not know how to rich the specific li that conatins :"text2" and "insideText2".
Please help.
Thanks.





What does the word "concat" actually or originally mean?

Recently I am reading a copy of source code from somewhere written in Java.



There's a statement of a method likes:



public static <T> List<T> concat(List<T>... lists){
...
}


and I wonder that whether it's suitable to name it "concat"? Originally, what does the word "concat" mean? Does it mean "CONnect ChAracTer" or other?





How to setup FCK editor in Yii?

I'm new to Yii framework,
I need an FCK editor for my CMS management page. I downloaded and extracted the FCKeditor to the root folder and its extension in yii extension folder. and i added the following code in my view



<?php $this->widget('application.extensions.fckeditor.FCKEditorWidget',array(
"model"=>$model, # Data-Model
"attribute"=>'content', # Attribute in the Data-Model
"height"=>'400px',
"width"=>'100%',
"toolbarSet"=>'Basic', # EXISTING(!) Toolbar (see: fckeditor.js)
"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",
# Path to fckeditor.php
"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",
# Realtive Path to the Editor (from Web-Root)
"config" => array(
"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',),
# http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
# Additional Parameter (Can't configure a Toolbar dynamicly)
) ); ?>


These all are working fine.
but the editor is displayed separatly. i need the editor in place of content textarea.enter image description here





Length of the shortest phrase with given keywords in a large text

This question was asked to one of my friends in an interview.



Given two keywords, we have to find the length of the shortest phrase with the given keywords in a large text.
The keywords may appear in any order in that text.
Constraint : Keep an efficient data structure so that each time the text need not be parsed for queries with different keywords




eg. keywords: "one", "four" text: "one two three four five four six
one"



here the shortest such phrase is "four six one" rather than "one two
three four"




The solution we have in mind is:
Built a BST with all the words of the text. Each node maintains the locations of the words.
(This will be a sorted list) When a query comes search [O(logn)] both words, Find the minimum difference between their locations in [O(n)] Thus making it effectively [O (nlogn)].



Can we do better ?





How to write a VBS Script to Repair a Corrupted Excel File?

How can we write a VBS Script to repair an invalid sheet name in Excel?



When we open the file in Excel, we get three dialog boxes, presenting us with errors - the third being the 'Repairs to 'Bad.xls''.



My question is, how can we write a VBS Script to do this automatically so that we can process large numbers of files?





Android JNI functions run on main thread?

I have a doubt regarding JNI function calls made from Android. Do they run on the same thread as the Android app? Will the UI freeze if the native function is taking more time to run?





Open prezi from app

I'm trying to open a prezi.com presentation from my app.



NSURL *url = [ [ NSURL alloc ] initWithString: @"prezi://open?oid=ftv9hvziwqi2" ];
[[UIApplication sharedApplication] openURL:url];


This piece of code opens the app, but not the presentation. When you visit this link on your ipad you get a page with a link the open the presentation.



http://prezi.com/ftv9hvziwqi2/coca-cola-companya/



But I can figure out the correct URL for opening a presentation in the prezi app. And i cant find any documentation from this either on the prezi site.





Classic form to XPAGES

I have a classic lotus notes form with 1800 fields and 7 tab,




  1. Will the performance improvement if i split the form in 7 different form and then bind to the xpages
    or

  2. if i directly bind the form to the xpages will there be any performance impact?



thanks





How does the man in the middle attack work in Diffie–Hellman?

I'm doubt about the mechanism of man in the middle attack in Diffie–Hellman key exchange. I have heard that it can be happened in the key agreement communication. But in the presence of CA (Certificate Authority) the receiver can authenticate the sender as he received the public key of the sender whoever he is. Therefore, how that man in the middle attack is possible????





Slot-machine-style logotype stripe

I am looking for a component to display affiliates' logotypes, preferably jQuery, then Flash, in a page-wide stripe (say: 800x100px). One that is fully automated, does not engage user operation and displays images much like a slot machine (one-armed bandit).



Can anybody recommend one, please?



(Or maybe I'm missing a jargon call for it and my searches are in vain...)





Set PHP configuration settings in application.ini

I forget how I can set PHP configuration settings from the application.ini of Zend Framework.



I want to set max_execution_time variable.



Help me please.





how to authenticate desktop application using java and restfb api

I am using restfb api and Java language. But my main concern is that how i authenticate my user, i mean how to take them to the login window and take the access token from the browser window.