Search Results

Search found 78 results on 4 pages for 'srinivas iyer'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • How do I write a custom validator for a zend form element with customized error messages?

    - by Mallika Iyer
    I have a question field with a list of allowed characters : A-Z,0-9,colon (:), question mark (?), comma(,), hyphen(-), apostrophe ('). I have the regex which works fine, in the fashion : $question->addValidator('regex', true, array(<regular expresstion>)) The default error message is something like ''' does not match against pattern '' I want to write a custom error message that says ' is not allowed in this field' Is there a simple way to do it using the existing zend components that I'm missing? Is writing a custom validator the only way to achieve what I'm trying to achieve? If yes, how do I write a custom validator (I looked at the documentation and didn't quite understand how I can customize the error messages) If there is any other way, I'd most appreciate that input too. Thanks for taking the time to answer this!

    Read the article

  • Most useful Rails plugins, Ruby libraries and Ruby gems?

    - by Srinivas Iyer
    I have seen many sites which provide the whole list of Rails plugins, Ruby libraries and Ruby gems, but we hardly use few of them and some may not suit our requirement and we spend a whole lot of time searching for useful plugins which suits our requirement. I have created this poll, people can post useful libraries, gems and plugins which they have come across. It would be great help for newbies like me and to the entire Ruby on Rails community. Note: to keep this poll as useful as possible, please remember: Post only one library, gem, or plugin per answer Mention the name of the library, gem, or plugin which you find it useful. URL of the location of the resource We don't want duplicate answers, so before posting check if the library has been mentioned already. Thanks

    Read the article

  • Problem retrieving values from Zend_Form_SubForms - no values returned

    - by anu iyer
    I have a Zend_Form that has 4 or more subforms. /** Code Snippet **/ $bigForm = new Zend_Form(); $littleForm1 = new Form_LittleForm1(); $littleForm1->setMethod('post'); $littleForm2 = new Form_LittleForm2(); $littleForm2->setMethod('post'); $bigForm->addSubForm($littleForm1,'littleForm1',0); $bigForm->addSubForm($littleForm2,'littleForm2',0); On clicking the 'submit' button, I'm trying to print out the values entered into the forms, like so: /** Code snippet, currently not validating, just printing **/ if($this-_request-getPost()){ $formData = array(); foreach($bigForm->getSubForms() as $subForm){ $formData = array_merge($formData, $subForm->getValues()); } /* Testing */ echo "<pre>"; print_r($formData); echo "</pre>"; } The end result is that - all the elements in the form do get printed, but the values entered before posting the form don't get printed. Any thoughts are appreciated...I have run around circles working on this! Thanks in advance!

    Read the article

  • Zend RegEx Validator error message issue

    - by Mallika Iyer
    Hello, I'm validating a text field in my form as follows: $name = new Zend_Form_Element_Text('name'); $name->setLabel('First Name:') ->setRequired(true) ->addFilter(new Zend_Filter_StringTrim()) ->addValidator('regex',true,array('/^[(a-zA-Z0-9)]+$/')) ->addErrorMessage('Please enter a valid first name'); What I'm trying to accomplish is - how can i display a meaningful error message? Eg: If first name is 'XYZ-', how can i display '- is not allowed in first name.' Is there a way I can access what character the regex is failing for? Would you recommend something else altogether? I thought about writing a custom validator but the regex is pretty simple, so I don't see the point. I couldn't find a decent documentation for the zend 'regex' validator anywhere. If I don't override the default error message, I simple get something like : ';;;hhbhbhb' does not match against pattern '/^[(a-zA-Z0-9)]+$/' - which I obviously don't want to display to the user. I'd appreciate your inputs.

    Read the article

  • Setting the inner html text of a < span > element using Zend_Form_Decorators

    - by Mallika Iyer
    I'm trying to set the inner html of the < span tag here , so it looks like: Group this is what i have so far: $form->addDisplayGroup( array( ................ ), 'maingroup1', array( 'legend'=>'', 'disableDefaultDecorators'=> true, 'decorators'=> array('FormElements', array('FieldSet',array('class'=>'dashed-outline2')), array(array('SpanTag' => 'HtmlTag'), array('tag'=>'span','class' => 'group',)), array('HtmlTag',array('tag'=>'div','id'=>'group1','class'=>'group','openOnly'=> true)) ) ) ); Is there a setter / property that I can use to set the inner text of the < span element using Zend_form_decorators? Thanks.

    Read the article

  • Error with Drools .brl to .drl rule conversion - Adding dynamic rules

    - by jillika iyer
    Hi, I want to add rules dynamically in drools. What is the main plus point of using KNowledge builder?? Or is it better to just list the Files in the rules directory and add it to my program?? But in this case when I convert from a .brl to .drl file at runtime - my new created .drl is not detected. How can I update the new rule and add it at runtime?? Please help. Thank you J

    Read the article

  • PHP unit tests for controller returns no errors and no success message.

    - by Mallika Iyer
    I'm using the zend modular director structure, i.e. application modules users controllers . . lessons reports blog I have a unit test for a controller in 'blog' that goes something like the below section of code: I'm definitely doing something very wrong, or missing something - as when i run the test, i get no error, no success message (that goes usually like ...OK (2 tests, 2 assertions)). I get all the text from layout.phtml, where i have the global site layout. This is my first endeavor writing a unittest for zend-M-V-C structure so probably I'm missing something important? Here goes.... require_once '../../../../public/index.php'; require_once '../../../../application/Bootstrap.php'; require_once '../../../../application/modules/blog/controllers/BrowseController.php'; require_once '../../../TestConfiguration.php'; class Blog_BrowseControllerTest extends Zend_Test_PHPUnit_ControllerTestCase { public function setUp() { $this->bootstrap = array($this, 'appBootstrap'); Blog_BrowseController::setUp(); } public function appBootstrap() { require_once dirname(__FILE__) . '/../../bootstrap.php'; } public function testAction() { $this->dispatch('/'); $this->assertController('browse'); $this->assertAction('index'); } public function tearDown() { $this->resetRequest(); $this->resetResponse(); Blog_BrowseController::tearDown(); } }

    Read the article

  • How to override a class method of the gem in rails Application ?

    - by Srinivas Iyer
    Hi, Best practice to Override a class method of the gem in rails Application . I need to override the behaviour of the find method of a gem. following is the code in the gem module Youtube class display attr_accessor :base def find(id, options = {}) detailed = convert_to_number(options.delete(:detailed)) options[:detailed] = detailed unless detailed.nil? base.send :get, "/get_youtube", options.merge(:youtube_id => id) end end end How do i override the above find method in my YoutubeSearch Controller of Rails Application ? def find(id, options = {}) //Code here end Thanks

    Read the article

  • How can I add a plugin to the registry while using a Zend_Form?

    - by Mallika Iyer
    I have a zend form that I'm initializing as follows: $form = new Form_XYZ(); I have a display group in that form, which I'm calling like this: $form->addDisplayGroup($generalSettingsGroup, 'general', array( 'legend' => 'General', 'disableDefaultDecorators' => true, 'decorators' => array( 'FormElements', 'FieldSet', array('HtmlTag', array('tag' => 'div', 'class' => 'general') ) ) ) ); I get this error : ArrayObject Object ( [exception] => Zend_Loader_PluginLoader_Exception Object ( [message:protected] => Plugin by name 'FieldSet' was not found in the registry; used paths:Zend_Form_Decorator_: Zend/Form/Decorator/ [string:private] => [code:protected] => 0 [file:protected] => /usr/share/pear/PEAR/Zend/Loader/PluginLoader.php [line:protected] => 406 [trace:private] => Array ................... How can I add the FieldSet plugin to the registry? I'm using the default Zend_Form Fieldset decorator.

    Read the article

  • How can I set the class for a <dt> element in a Zend_Form?

    - by Mallika Iyer
    I'm trying to set the width of the style for a group of < dt elements in a Zend_Form. Is there a way to set a class for a dt element, so the end result would be something like this: <dt id="name-label" class="xyz" > // trying to add the 'class="xyz" <label class="required" for="name">Name:</label> </dt> <dd id="name-element"> <input type="text" maxlength="255" size="30" value="" id="name" name="name"> </dd>

    Read the article

  • A question on delegates and method parameters

    - by Srinivas Reddy Thatiparthy
    public class Program { delegate void Srini(string param); static void Main(string[] args) { Srini sr = new Srini(PrintHello1); sr += new Srini(PrintHello2); //case 2: sr += new Srini(delegate(string o) { Console.WriteLine(o); }); sr += new Srini(delegate(object o) { Console.WriteLine(o.ToString()); }); //case 4: sr += new Srini(delegate { Console.WriteLine(“This line is accepted,though the method signature is not Comp”); });//case 5 sr("Hello World"); Console.Read(); } static void PrintHello1(string param) { Console.WriteLine(param); } static void PrintHello2(object param) { Console.WriteLine(param); } } Compiler doesn't complain about the case 2(see the comment),well,the reason is straight forward since string inherits from object. ,along the same lines ,Why is it complaining for anonymous method types(see the comment //case 4:) that “Cannot convert anonymous method to delegate type 'DelegateTest.Program.Srini' because the parameter types do not match the delegate parameter types” where as in case of normal method it doesn't ?or am i comparing apples with oranges? Another case is why is it accepting anonymous method without parameters?

    Read the article

  • How can I append a description to a Zend_Form_Element?

    - by Mallika Iyer
    I have the following Zend_Form_Element: $imginstructions = "Some description"; $img = $this->createElement('select','img'); $img->setAttrib('class', 'image-select'); $imgdecorator = $img->getDecorator('Description'); $imgdecorator->setOption('escape', false); $img->setLabel('Image:') ->setRequired(true) ->addMultiOptions($images) ->setValue('') ->setDescription($imginstructions) ->addErrorMessage('You must select an image'); $img->size = 5; $this->addElement($img); The description should appear next to the select box. The problem is : When an error is thrown, the html rendered changes so the description shows up below the select box, instead of beside it. HTML rendered before error is thrown: <dd id="img-element"> <select size="5" class="image-select" id="img" name="img" style="display: none;"> ...........options.............. </select> <p class="description">Some Description</p></dd> HTML rendered after error is thrown: <dd id="img-element"> <select size="5" class="image-select" id="img" name="img" style="display: none;"> ...........options.............. </select> <ul class="errors"><li>You must select an image</li></ul> <p class="description">Some Description</p></dd> Is there a way to force the error message to be appended as the last element in the DOM tree for the dd element? Something like: <dd id="img-element"> <select size="5" class="image-select" id="img" name="img" style="display: none;"> ...........options.............. </select> <p class="description">Some Description</p> <ul class="errors"><li>You must select an image</li></ul></dd> so the 'ul' is at the end of the dd DOM tree. Thanks, I appreciate your taking the time to respond to this question!

    Read the article

  • Problem with DSL and Business Rules creation in Drools

    - by jillika iyer
    Hi, I am using Eclipse with the Drools plugin to create rules. I want to create business rules and main aim is to try and provide the user a set of options which he can use to create rules. For eg:If an Apple can have only 3 colors: I want to provide an option like a drop down so that the user can know before hand which are the options he can use in his rules. Is it possible? I am creating a dsl but unable to still provide the above functionality for a business rule. I am having an error implementing a basic dsl also. The code to add the dsl is as follows in my RuleRunner class() InputStream ruleSource = RuleRunner.class.getClassLoader().getResourceAsStream("/Rule1.dslr"); InputStream dslSource = RuleRunner.class.getClassLoader().getResourceAsStream("/sample-dsl.dsl"); //Load the rules , using DSL addRulesToThisPackage.addPackageFromDrl( new InputStreamReader(ruleSource),new InputStreamReader(dslSource)); I have both the sample-dsl .dsl and Rule1.dslr in my working directory. Error encountered at adding the dsl to the package (last line) Error stack: Exception in thread "main" java.lang.NullPointerException at java.io.Reader.<init>(Unknown Source) at java.io.InputStreamReader.<init>(Unknown Source) at com.org.RuleRunner.loadRuleFile(RuleRunner.java:96) at com.org.RuleRunner.loadRules(RuleRunner.java:48) at com.org.RuleRunner.runStatelessRules(RuleRunner.java:109) at com.org.RulesTest.main(RulesTest.java:41) my dsl file has basic mapping as per the online documentations. The dsl rule I created is: expander sample-dsl.dsl rule "A status changes B status" when There is an A - has an address There is a B - has name then - print updated A and Aaddress End I have created DSL in eclipse. Is the code I added for it to be loaded to my package correct?? Or am I missing something???? It seems like my program is unable to find the dsl? Please help. Can you point me towards the right direction to create a user friendly business rule ?? Thanks. J

    Read the article

  • Selective emboldeing of text in a webpage

    - by Eknath Iyer
    while printing out utf-8 characters onto a webpage, if encapsulate them with they get emboldened, but anything else, the page turns blank. Why? def main(): print "Content-type: text/html\r\n\r\n"; print '<html>' print '<head>' print '<style type="text/css">' print '.highlight { background-color: yellow }' print '.color1 { color: green; }' print '.color2 { color: blue; }' print '.color3 { color: purple; }' print '.color4 { color: red; }' print '.color5 { color: teal; }' print '.color6 { color: yellow; }' print '.color7 { color: orange; }' print '.color8 { color: violet; }' print '</style></head>' print '<body>' form = cgi.FieldStorage() ch = form.getvalue('choice') if ch == 'English': in_sent = form.getvalue('f1') in_sent = in_sent.lower() cho=0 elif ch == 'Hindi': in_sent = trans_he(form.getvalue('transl1').decode("utf-8")).strip() cho=1 #cho = 0 for english #cho = 1 for hindi adict=[] print '<center><u> User Input Sentence ==> <b>', in_sent,'</b></u></center><br>' in_sent=in_sent.strip().split(' ') colordict={} counter=1 for word in in_sent: colordict[word]=counter counter = counter + 1 f = open('bidirectional.alignment.txt','rb').read() records=f.strip().split('\n\n\n') for record in records: el=[] el2 = [] #basic file processing is done here. record = record.strip().split('\n') source = record[cho] target = record[(cho+1)%2] source_sent = source.split(' # ')[1] target_sent = target.split(' # ')[1] source_words = source_sent.strip().split(' ') target_words = target_sent.strip().split(' ') trans_index = source.split(' # ')[2].strip().split(' ') for word in in_sent: if word in source_words: if int(trans_index[source_words.index(word)]) > 0: tword=target_words[(int(trans_index[source_words.index(word)])-1)] target_sent = target_sent.replace(tword+' ','<b>'+tword+' </b>') # When the <b> tag is used here(for the 'target_sent = ...' statement). it is fine. But when <b> is replaced by something like in the next line or even <i> or <u>, it doesn't show an output at all source_sent = source_sent.replace(word+' ','<span class="color1">'+word+' </span>') el2.append(source_sent) el2.append(target_sent) el.append(target_sent.count('<b>')) el.append(el2) if target_sent.count('<b>') > 0: adict.append(el) print '<table><tr><td><center><h1>SOURCE LANGUAGE</h1></center></td><td><center> <h1>TARGET LANGUAGE</h1></center></td></tr>' for entry in adict: print '<tr><td>',entry[1][0],'</td><td>',trans_eh(entry[1][1]).encode("utf-8"),'</td> </tr>' print '</table></body>' print '</html>' main()

    Read the article

  • Risking the exception anti-pattern.. with some modifications

    - by Sridhar Iyer
    Lets say that I have a library which runs 24x7 on certain machines. Even if the code is rock solid, a hardware fault can sooner or later trigger an exception. I would like to have some sort of failsafe in position for events like this. One approach would be to write wrapper functions that encapsulate each api a: returnCode=DEFAULT; try { returnCode=libraryAPI1(); } catch(...) { returnCode=BAD; } return returnCode; The caller of the library then restarts the whole thread, reinitializes the module if the returnCode is bad. Things CAN go horribly wrong. E.g. if the try block(or libraryAPI1()) had: func1(); char *x=malloc(1000); func2(); if func2() throws an exception, x will never be freed. On a similar vein, file corruption is a possible outcome. Could you please tell me what other things can possibly go wrong in this scenario?

    Read the article

  • Text box added using javascript doesnot respond as expected to the js attached to it.

    - by Mallika Iyer
    Hello, I am adding a text box using javascript: This is what is generated: <dd id="text3-element" style="width: 350px;"> <input type="text" size="50" id="text3" name="text3" onblur="return getFieldValue(this.id);" value=""> </dd> This is what is present in the getFieldValue function: function getFieldValue(id){ var elem = document.getElementById(id); alert(elem.value); return false; } I'm trying to get the value of the field added using javascript when the value of the filed changes. However, I keep getting the value as 'undefined', in spite of entering text into the newly added text box. This does not happen if the form already has a text box to begin with - i.e., if a text box is not being added via a js function. Anything missing / look wrong here? Thanks!

    Read the article

  • How to display Unicode data with PHP

    - by Srinivas Tamada
    table 'abc' data : tid title 1 ????????????? ?. 2 ?????? ?????? $sql=mysql_query("select title from abd where tid='1'"); $row=mysql_fetch_array($sql); $title = $row['title']; echo $title; OutPut displaying like this: ???????????????? But I want to display ????????????? ?.

    Read the article

  • While using the latest CKeditor (v.3.1), does anyone encounter a stray select box on the page where

    - by Mallika Iyer
    Hello, I'm using the CKEditor 3.1, and find that whereever there is a box on the page, the ckeditor causes a new empty select box to appear next to it (although it has not been applied to that specific element.) This seems to be a known issue : http://dev.fckeditor.net/ticket/4528 Has anyone been able to get around that? Is there any other good fckeditors you can suggest? Thanks!

    Read the article

  • Javascript onclick event is not working in internet explorer 8.

    - by Mallika Iyer
    Hi, I have the following line of code that works fine in Firefox, Chrome and Safari, but not in internet explorer 8. <a href="javascript:void(0);" onclick="showHide('reading','type_r','r');">Show me the example</a> The function simply shows and hides a div on clicking the hyperlink. Is there anything I'm missing here? This is the showHide function: function showHide(elementId,parentId,qtype) { if (document.getElementById && !document.all) { var elementParent = document.getElementById(parentId); var element = document.getElementById(elementId); var upArrowId = 'up-arrow-'+qtype; var downArrowId = 'down-arrow-'+qtype; if(element.style.visibility == 'hidden'){ elementParent.style.height = 'auto'; element.style.visibility = 'visible'; document.getElementById(upArrowId).style.visibility = 'visible'; document.getElementById(downArrowId).style.visibility = 'hidden'; } else if(element.style.visibility == 'visible'){ element.style.visibility = 'hidden'; elementParent.style.height = '50px'; document.getElementById(upArrowId).style.visibility = 'hidden'; document.getElementById(downArrowId).style.visibility = 'visible'; } } } Thanks.

    Read the article

< Previous Page | 1 2 3 4  | Next Page >