Field.get(obj) returns all nulls on injected CDI managed beans, while manually invoking getters return correct values

I am trying to access the values of some fields from the backing bean of a JSF page via reflection. The problem is that when I use the getter I get the correct value but when I use the get(obj) method of the necessary fields I always get a null value returned. Getting the beanObject: ELContext elcontext = FacesContext.getCurrentInstance().getELContext(); Object beanObject = FacesContext.getCu

Field.get(obj)返回注入的CDI托管bean上的所有空值,而手动调用getter返回正确的值

我正在尝试通过反射访问JSF页面的支持bean中的某些字段的值。 问题是,当我使用getter时,我得到了正确的值,但是当我使用必要字段的get(obj)方法时,我总是得到返回的空值。 获取beanObject: ELContext elcontext = FacesContext.getCurrentInstance().getELContext(); Object beanObject = FacesContext.getCurrentInstance().getApplication().getELResolver().getValue(elcontext, null, beanName); 要在不使用gette

@Nullable annotation usage

I saw some method in java declared as: void foo(@Nullable Object obj) { ... } What's the meaning of @Nullable here? Does it mean the input could be null ? Without the annotation, the input can still be null, so I guess that's not just it? Thanks It makes it clear that the method accepts null values, and that if you override the method, you should also accept null values. It also

@Nullable注释用法

我看到java中的一些方法声明为: void foo(@Nullable Object obj) { ... } @Nullable的含义是@Nullable ? 这是否意味着输入可能为null ? 没有注释,输入仍然可以为空,所以我猜这不仅仅是它? 谢谢 它明确表示该方法接受空值,并且如果重写该方法,则还应该接受空值。 它也可以作为FindBugs之类的代码分析器的提示。 例如,如果这种方法首先不检查空值而解引用其参数,则FindBugs将发出警告。 此注释通常用于消除

Should Java 8 getters return optional type?

Optional type introduced in Java 8 is a new thing for many developers. Is a getter method returning Optional<Foo> type in place of the classic Foo a good practice? Assume that the value can be null . Of course, people will do what they want. But we did have a clear intention when adding this feature, and it was not to be a general purpose Maybe or Some type, as much as many people wou

Java 8 getters应该返回可选类型吗?

在Java 8中引入的Optional类型对许多开发人员来说是一个新事物。 一个getter方法返回Optional<Foo>类型来代替经典的Foo是一种好的做法吗? 假定该值可以为null 。 当然,人们会做他们想做的事。 但是,我们在添加此功能时的确有明确的意图,并且它不是一个普通用途的可能或某种类型,尽可能多的人会喜欢我们这样做。 我们的目的是为库方法返回类型提供一个有限的机制,其中需要有一种清晰的方式来表示“无结果”,并

How to create custom javadoc tags?

How do I create custom javadoc tags such as @pre / @post? I found some links that explain it but I haven't had luck with them. These are some of the links: http://www.developer.com/java/other/article.php/3085991/Javadoc-Programming.html http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html java code /** * @custom.mytag hey ho... */ java doc option -tag custom.mytag:a:

如何创建自定义javadoc标签?

如何创建自定义javadoc标签,如@pre / @post? 我发现了一些解释它的链接,但我没有和他们碰运气。 这些是一些链接: http://www.developer.com/java/other/article.php/3085991/Javadoc-Programming.html http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html java代码 /** * @custom.mytag hey ho... */ java doc选项 -tag custom.mytag:a:"This is my Tag:" 产量 这是我的标签: 嘿嘿...

How to create two interfaces to a Java class one read

I'm writing a game engine in Java for a two player card game for which my students are going to write AI players. The AI players will take turns playing cards onto their 'field' a part of the 'table' in front of them. They can attack with a card from their field a card in the other player's field. Cards may be face up or face down. The GameEngine class allows an AI p

如何为一个读取的Java类创建两个接口

我正在用Java编写一个游戏引擎,用于我的学生将要编写AI玩家的双人牌游戏。 人工智能玩家将轮流在他们的“场地”上打牌,作为他们面前的“桌子”的一部分。 他们可以在其他球员的场上用卡从他们的场上攻击。 卡可能面朝上或面朝下。 GameEngine类允许AI玩家通过调用GamePlayer.TakeTurn(GameEngine eng)方法轮到他/她。 玩家可以向游戏引擎询问卫冕玩家的场地,以便玩家可以根据卡牌数量以及哪些卡牌正面朝上做出决定。 假

How can one set javadoc options in a wrapper of the standard doclet?

The UMLGraph doclet UmlGraphDoc first runs the standard Java doclet with code like the following: public static boolean start(RootDoc root) { com.sun.tools.doclets.standard.Standard.start(root); and then modifies the result to add UML class diagrams. The UMLGraph doclets introduce a number of custom tags, such as @depend and @has . Custom tags can be specified using the Taglet interface

如何在标准doclet的包装中设置javadoc选项?

UMLGraph doclet UmlGraphDoc首先运行标准的Java doclet,代码如下: public static boolean start(RootDoc root) { com.sun.tools.doclets.standard.Standard.start(root); 然后修改结果以添加UML类图。 UMLGraph doclet引入了一些自定义标签,例如@depend和@has 。 自定义标签可以使用Taglet接口指定,并通过-taglet和-tagletpath选项传递给javadoc。 我的问题是:当从另一个doclet调用这些选项时,如何将这些选项指

How to reference a method in javadoc?

How can I use the @link tag to link to a method? I want to change /** * Returns the Baz object owned by the Bar object owned by Foo owned by this. * A convenience method, equivalent to getFoo().getBar().getBaz() * @return baz */ public Baz fooBarBaz() to /** * Returns the Baz object owned by the Bar object owned by Foo owned by this. * A convenience method, equivalent to {@link getFoo(

如何引用javadoc中的方法?

如何使用@link标记链接到方法? 我想改变 /** * Returns the Baz object owned by the Bar object owned by Foo owned by this. * A convenience method, equivalent to getFoo().getBar().getBaz() * @return baz */ public Baz fooBarBaz() 至 /** * Returns the Baz object owned by the Bar object owned by Foo owned by this. * A convenience method, equivalent to {@link getFoo()}.{@link getBar()}.{@link

How to use Javadoc options (such as

I would like to generate javadoc but excluding deprecated methods from it. I know there's an option called -notdeprecated (which does what I need) but I can't figure out how to specify this option. To produce javadoc I go to Project->Generate Javadoc. There I can choose between 'use standard doclet' and 'use custom doclet'. I think I should use custom doclet to use

如何使用Javadoc选项(比如

我想生成javadoc,但不包括已弃用的方法。 我知道有一个选项叫做-notdeprecated(这是我所需要的),但我无法弄清楚如何指定这个选项。 为了生成javadoc,我转到Project-> Generate Javadoc。 在那里我可以选择'使用标准doclet'和'使用自定义doclet'。 我想我应该使用自定义doclet来使用选项(我错了吗?)。 现在,在哪里以及如何指定选项? 我使用Eclipse 3.4.2 至少在Eclipse 3.5中,在向导的第三

Linking to an external URL in Javadoc?

就像是: /** * See {@linktourl http://google.com} */ This creates a "See Also" heading containing the link, ie: /** * @see <a href="http://google.com">http://google.com</a> */ will render as: See Also: http://google.com whereas this: /** * See <a href="http://google.com">http://google.com</a> */ will create an in-line link: See http://google.com

链接到Javadoc中的外部URL?

就像是: /** * See {@linktourl http://google.com} */ 这会创建一个包含链接的“另请参见”标题,即: /** * @see <a href="http://google.com">http://google.com</a> */ 将呈现为: 也可以看看: http://google.com 而这个: /** * See <a href="http://google.com">http://google.com</a> */ 将创建一个内联链接: 请参阅http://google.com 采取从javadoc规格 @see <a href

Multiple line code example in Javadoc comment

I have a small code example I want to include in the Javadoc comment for a method. /** * -- ex: looping through List of Map objects -- * <code> * for (int i = 0; i < list.size(); i++) { * Map map = (Map)list.get(i); * System.out.println(map.get("wordID")); * System.out.println(map.get("word")); * } * </code> * * @param query - select statement * @return

Javadoc评论中有多行代码示例

我有一个我想包含在Javadoc注释中的小代码示例。 /** * -- ex: looping through List of Map objects -- * <code> * for (int i = 0; i < list.size(); i++) { * Map map = (Map)list.get(i); * System.out.println(map.get("wordID")); * System.out.println(map.get("word")); * } * </code> * * @param query - select statement * @return List of Map objects */ 问题是代码