关于在JSF中开发自定义组件,我有一些事情很难理解.出于这些问题的目的,您可以假设所有自定义控件都使用值绑定/表达式(不是文字绑定),但我也对它们的解释感兴趣.
我已经尝试了一些组合,但最终总是很难找到我认为来自对事件生命周期的基本误解的错误.
如标题中所述,我在Visual Studio项目中复制了我的DLL,将其设置为"content"和"始终复制".添加了对此DLL的引用并将其设置为"本地复制".
我成功地通过代码将我的组件实例化为表单,但它没有出现在工具箱中,真的很无聊.
我该如何解决这个问题?
如果我直接将DLL项目链接到这个项目它可以工作,但现在我将DLL视为"外部",因此它不是DLL项目的同一解决方案的一部分.
我想创建一个自定义的JSF 2.0组件,但无法使其工作.我的组件定义如下:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }
Run Code Online (Sandbox Code Playgroud)
taglib看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
<namespace>http://www.company.com/tags</namespace>
<tag>
<tag-name>custom</tag-name>
<component>
<component-type>myCustomComponent</component-type>
</component>
</tag>
</facelet-taglib>
Run Code Online (Sandbox Code Playgroud)
我的faces-config看起来像这样:
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.
Run Code Online (Sandbox Code Playgroud)
不确定它是否重要,但我在这里使用Spring 3.1和JSF 2.1.所以依赖关系由Spring管理.
知道这里发生了什么吗?
解:
看起来Spring就是这里的坏人.我已从__CODE__组件中删除了注释,并在我的faces-config中定义了它,如下所示:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { …Run Code Online (Sandbox Code Playgroud) 我想制作像图片中提到的菜单,这些菜单将适用于android.

如果你看到左半圈的图像被显示.我想在旋转后旋转这个圆圈,它会显示其他隐藏的菜单.此外,还将显示中心主菜单的右子菜单.
我已经创建了一个自定义视图,onDraw()覆盖了画布上的位图.当我在布局文件中指定我想要它wrap_content时,它仍然会填满整个屏幕.onMeasure()这样说:
measure的基类实现默认为背景大小,除非允许更大的大小
MeasureSpec.子类应覆盖onMeasure(int,int)以提供更好的内容测量.
好酷,所以我知道我需要覆盖onMeasure()和使用MeasureSpec.根据这个答案
unex表示layout_width或layout_height值设置为wrap_content.你可以任意大小.
现在我遇到了我的问题,我如何onMeasure()测量我尚未创建的位图并测量/包装它?我知道其他Android视图必须做一些事情,因为如果设置为wrap_content,它们不会阻挡整个屏幕.提前致谢!
(更多包/组件为我安装乐趣 - 感谢大家为您提供的所有帮助).
我在Delphi 2007中将错误列为标题.包A是我的基于框架的"查看器面板"包.包B是含有几个组件,这些组件用于显示关于链接到数据库gven(它们的SQL,状态,类型,等),其中之一是一个非可视组件数据集的信息的包(我们将称之为Inspector)创建并调用显示该信息的表单.单位X是该表格的单位.
我加入了督察组分在包我的观众面板之一,但此后删除了它,并不能找到在查看源代码,为项目的任何引用,也不在基于帧的查看器面板的单位我把它添加到.引用隐藏在哪里?
另外,将Inspector组件添加到其中一个视图面板框架(也作为已注册的组件安装)会导致此问题?
这可能与之前的问题和这个问题有关,但我决定从这个特定的symtpom /问题开始,只是为了保持简洁明了,希望以后对其他人有用.在此先感谢您的帮助.
更新:
感谢Loren,我能够找到并删除仍然存在并导致问题的USES引用.但是,我仍然不清楚如何完成我想要完成的任务.:\这是最新的:
Inspector是一个简单的非可视组件,它包含一个DataSet属性和一个内部"Info Form".调用ShowInfo方法会创建表单,并使用与链接的DataSet相关的各种信息填充该表单.我想用它来调试驱动观众的SQL.
如上所述,Inspector包含在包B中.查看器位于包A中.我想在某些TFrame后代(注册为真正的调色板组件)上使用Inspector组件.当我将该组件放在给定的TFrame上然后使用它,并编译/安装包A时,我得到"无法加载包A,它包含单元X,它也包含在包B中"错误.它现在显然是原因,我可以按需重新创建问题.
moobaa的建议在下面是有道理的,但似乎即使我试图做他所建议的方法#2,它也行不通.我错过了什么?看起来这应该是可行的,事实上,似乎我见过的大多数软件包一直使用其他已安装的软件包(包括VCL本身).
注意:据我所知,包B不依赖于包A(我已经单独安装它,所以这似乎同意).
(顺便说一句,是否有任何工具来"规划"这样的包依赖?我正在使用D2007)
一如既往,感谢您的时间和帮助.
我需要创建继承自TCustomControl的透明组件..因此它是自定义绘制的,但是是其他组件的容器.
你能告诉我怎么做到这一点吗?
I using custom switch for support of API 8. I am using THIS Libarary for Custom Switch. But I want to make something Like show in figure.I have tried to change the color ,though changing the color in the style but doesn't effect as i want.

Please help me , Thanks in advance.
我已经创建了一个基于TPaintBox的组件TGridPaintBox.它基本上是一个添加了"网格功能"的绘图箱.它不是数据网格.更像是棋盘组件.
在对象资源管理器中,我可以设置某些属性.最重要的是,我可以设置网格尺寸(横跨/向下有多少个单元格),还可以设置与绘图相关的选项.细胞是否应该是正方形,奇数/偶数细胞的颜色等.
我的第一个版本的组件直接在类上有属性,当我更改属性时,立即更新了设计时图.随着组件的增长,我想更好地组织我的属性,并引入了一些"选项属性",如绘图选项,行为选项等.在介绍之后,设计时绘图不再像以前那样更新.更改属性后,我必须单击组件才能更新.谁能告诉我为什么会这样?
这是代码的精简版本.我希望它能解释这种行为:
(PS:这是我的第一个组件,即使我自1997年以来一直使用Delphi,所以如果有人能像我做的那样发现任何愚蠢的东西,请随时告诉我)
unit GridPaintBox;
interface
type
TGridDrawOption = (gdoSquareCells,gdoCenterCells,gdoDrawCellEdges,gdoDrawFocus);
TGridDrawOptions = set of TGridDrawOption;
TGridOptions = class(TPersistent)
private
FCellsX : integer;
FCellsY : integer;
FDrawOptions : TGridDrawOptions;
public
constructor Create(aGridPaintBox : TGridPaintBox);
procedure Assign(Source : TPersistent); override;
published
property CellsX : integer read FCellsX write FCellsX;
property CellsY : integer read FCellsY write FCellsY;
property DrawOptions : TGridDrawOptions read FDrawOptions write FDrawOptions;
end;
TGridPaintBox = class(TPaintBox)
private
FGridOptions : TGridOptions;
FFocusedX,
FFocusedY : integer;
FOnFocusChanged: TNotifyEvent;
procedure …Run Code Online (Sandbox Code Playgroud) 我正在开发一个JSF自定义组件.该组件的目的是封装另一个组件(即PrimeFaces表)并向其添加自定义行为.例如,它支持的功能之一是从底层数据或某些属性动态创建PrimeFaces列.此外,它支持在XHTML中声明其他PrimeFaces列,这些列也应添加到封装的PrimeFaces表中.
考虑这个例子:
<my:table id="table" fields="title,label,value,additional">
<primefaces:column id="additional">
some content
</primefaces:column>
</my:table>
Run Code Online (Sandbox Code Playgroud)
我的自定义组件fields在渲染过程中从属性动态创建PrimeFaces列.然后它将所有column子项移动到PrimeFaces表,因此在呈现组件树之后如下所示:
my:table id="table"
|---primefaces:table id="table_table"
|---primefaces:column id="title"
|---primefaces:column id="label"
|---primefaces:column id="value"
|---primefaces:column id="additional"
Run Code Online (Sandbox Code Playgroud)
在第一次渲染期间,这很好.但是,当我然后执行我的组件的AJAX更新时,我得到以下异常:
javax.faces.FacesException: Cannot remove the same component twice: table:additional
at com.sun.faces.context.StateContext$DynamicAddRemoveListener.handleAddRemoveWithAutoPrune(StateContext.java:761)
at com.sun.faces.context.StateContext$DynamicAddRemoveListener.handleRemove(StateContext.java:629)
at com.sun.faces.context.StateContext$AddRemoveListener.processEvent(StateContext.java:342)
at com.sun.faces.context.StateContext$DynamicAddRemoveListener.processEvent(StateContext.java:565)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118)
at com.sun.faces.application.ApplicationImpl.processListenersAccountingForAdds(ApplicationImpl.java:2218)
at com.sun.faces.application.ApplicationImpl.invokeViewListenersFor(ApplicationImpl.java:2036)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:290)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:245)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:726)
at javax.faces.component.UIComponentBase.disconnectFromView(UIComponentBase.java:2275)
at javax.faces.component.UIComponentBase.doPreRemoveProcessing(UIComponentBase.java:1939)
at javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:437)
at javax.faces.component.UIComponentBase$ChildrenList.remove(UIComponentBase.java:2757)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.adjustIndexOfDynamicChildren(ComponentTagHandlerDelegateImpl.java:283)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:223)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:106)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:206)
at …Run Code Online (Sandbox Code Playgroud) custom-component ×10
android ×3
delphi ×3
components ×2
jsf ×2
dll ×1
java ×1
java-ee ×1
jsf-2 ×1
packages ×1
primefaces ×1
spring ×1
spring-boot ×1
toolbox ×1
vcl ×1
view ×1