default

Default action to execute when pressing enter in a form

穿精又带淫゛_ 提交于 2019-11-26 12:54:19
I've got a jsf 1.2 form with two buttons and several input fields. The first button discards the entered values and repopulates the page with values from a db, the second button saves the entered values. The problem occurs when the user presses enter while the cursor is in one of the input fields, the form gets submitted and the action associated with the first button gets executed. The code looks like this: <h:commandButton action="#{bean.reset}" value="Reset" /> <h:commandButton action="#{bean.save}" value="Save" /> <!-- h:datatable with several h:inputText elements --> Is it possible to

Is there a default type for numbers in Java

时间秒杀一切 提交于 2019-11-26 12:19:41
问题 If I write something like this System.out.println(18); Which type has the \'18\'? Is it int or byte ? Or doesn\'t it have a type yet? It can\'t be int, because something like this is correct: byte b = 3; And this is incorrect: int i = 3; byte bb = i; //error! EDIT: I think I found the right part in the spec at Assignment Conversion : The compile-time narrowing of constants means that code such as: byte theAnswer = 42; is allowed. Without the narrowing, the fact that the integer literal 42 has

Why should default parameters be added last in C++ functions?

守給你的承諾、 提交于 2019-11-26 12:19:29
问题 Why should default parameters be added last in C++ functions? 回答1: To simplify the language definition and keep code readable. void foo(int x = 2, int y); To call that and take advantage of the default value, you'd need syntax like this: foo(, 3); Which was probably felt to be too weird. Another alternative is specifying names in the argument list: foo(y : 3); A new symbol would have to be used because this already means something: foo(y = 3); // assign 3 to y and then pass y to foo. The

PHP sessions default timeout [duplicate]

放肆的年华 提交于 2019-11-26 12:16:21
问题 This question already has an answer here: How do I expire a PHP session after 30 minutes? 13 answers Do PHP sessions timeout by default - ie without any coding on my part would a user eventually be \"logged out\" after some time of inactivity? 回答1: It depends on the server configuration or the relevant directives session.gc_maxlifetime in php.ini . Typically the default is 24 minutes (1440 seconds), but your webhost may have altered the default to something else. 回答2: You can change it in you

Symfony2 Setting a default choice field selection

怎甘沉沦 提交于 2019-11-26 12:16:06
问题 I am creating a form in the following manner: $form = $this->createFormBuilder($breed) ->add(\'species\', \'entity\', array( \'class\' => \'BFPEduBundle:Item\', \'property\' => \'name\', \'query_builder\' => function(ItemRepository $er){ return $er->createQueryBuilder(\'i\') ->where(\"i.type = \'species\'\") ->orderBy(\'i.name\', \'ASC\'); })) ->add(\'breed\', \'text\', array(\'required\'=>true)) ->add(\'size\', \'textarea\', array(\'required\' => false)) ->getForm() How can I set a default

Why Is `Export Default Const` invalid?

放肆的年华 提交于 2019-11-26 11:45:59
问题 I see that the following is fine: const Tab = connect( mapState, mapDispatch )( Tabs ); export default Tab; However, this is incorrect: export default const Tab = connect( mapState, mapDispatch )( Tabs ); Yet this is fine: export default Tab = connect( mapState, mapDispatch )( Tabs ); Can this be explained please why const is invalid with export default ? Is it an unnecessary addition & anything declared as export default is presumed a const or such? 回答1: const is like let , it is a

What is an iterator&#39;s default value?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 11:28:25
问题 For any STL container that I\'m using, if I declare an iterator (of this particular container type) using the iterator\'s default constructor, what will the iterator be initialised to? For example, I have: std::list<void*> address_list; std::list<void*>::iterator iter; What will iter be initialised to? 回答1: By convention a "NULL iterator" for containers, which is used to indicate no result, compares equal to the result of container.end() . std::vector<X>::iterator iter = std::find(my_vec

Return a default value if no rows found

∥☆過路亽.° 提交于 2019-11-26 11:25:23
问题 I have the following select statement, to grab the next scheduled item for a stream. If there is no matching row, I want it to return a default value. Here\'s the line I\'m using: SELECT `file` FROM `show`, `schedule` WHERE `channel` = 1 AND `start_time` <= UNIX_TIMESTAMP() AND `start_time` > UNIX_TIMESTAMP()-1800 AND `show`.`id` = `schedule`.`file` ORDER BY `start_time` DESC LIMIT 1 That should grab the most recently scheduled item, but not if it\'s older than 30 minutes before the query.

PHP Default Function Parameter values, how to &#39;pass default value&#39; for &#39;not last&#39; parameters?

别说谁变了你拦得住时间么 提交于 2019-11-26 11:01:43
问题 Most of us know the following syntax: function funcName($param=\'value\'){ echo $param; } funcName(); Result: \"value\" We were wondering how to pass default values for the \'not last\' paramater? I know this terminology is way off, but a simple example would be: function funcName($param1=\'value1\',$param2=\'value2\'){ echo $param1.\"\\n\"; echo $param2.\"\\n\"; } How do we accomplsh the following: funcName(---default value of param1---,\'non default\'); Result: value1 not default Hope this

Using Default Arguments in a Function

痞子三分冷 提交于 2019-11-26 10:23:55
I am confused about default values for PHP functions. Say I have a function like this: function foo($blah, $x = "some value", $y = "some other value") { // code here! } What if I want to use the default argument for $x and set a different argument for $y? I have been experimenting with different ways and I am just getting more confused. For example, I tried these two: foo("blah", null, "test"); foo("blah", "", "test"); But both of those do not result in a proper default argument for $x. I have also tried to set it by variable name. foo("blah", $x, $y = "test"); I fully expected something like