关于JSF中托管bean之间的通信(Regarding communication between managed bean in JSF)
我之前关于托管bean的问题似乎并不清楚。 所以,我以更系统的方式再次发布它。
我有一页:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <ui:insert name="head"> </ui:insert> <br/><br/> <h:inputText value="#{MasterBean.laala}"/> <br/><br/> <ui:insert name="content"> </ui:insert> </h:body> </html>
这是它的豆子:
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean(name="MasterBean") @ViewScoped public class MasterBean { private String laala; public String getLaala() { return laala; } public void setLaala(String laala) { this.laala = laala; } public MasterBean() { } }
这是使用master.xhtml的data.xhtml:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <ui:composition template="master.xhtml"> <ui:define name="head"> laala </ui:define> <h:outputText value="#{pageBean.content}"/> <ui:define name="content"> <h:commandButton actionListener="#{pageBean.speakHello}"/> </ui:define>> </ui:composition> </h:body> </html>
这是它的豆子:
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean(name="pageBean") @ViewScoped public class pageBean { private String content; public String getContent() { return content; } public void setContent(String content) { this.content = content; } public void speakHello(){ //how do i get value of laaala here which is in MasterBean??? content = ??? + " Hello friend"; } public pageBean() { } }
我应该把空白放在哪里
???
在speakHello()中标记。 如何获得此bean中其他bean的值?It seems I am not clear on my previous question about managed bean. So, I am posting it again in a more systematic manner.
I have one page:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <ui:insert name="head"> </ui:insert> <br/><br/> <h:inputText value="#{MasterBean.laala}"/> <br/><br/> <ui:insert name="content"> </ui:insert> </h:body> </html>
This is its bean:
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean(name="MasterBean") @ViewScoped public class MasterBean { private String laala; public String getLaala() { return laala; } public void setLaala(String laala) { this.laala = laala; } public MasterBean() { } }
This is data.xhtml which uses master.xhtml:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <ui:composition template="master.xhtml"> <ui:define name="head"> laala </ui:define> <h:outputText value="#{pageBean.content}"/> <ui:define name="content"> <h:commandButton actionListener="#{pageBean.speakHello}"/> </ui:define>> </ui:composition> </h:body> </html>
This is its bean:
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean(name="pageBean") @ViewScoped public class pageBean { private String content; public String getContent() { return content; } public void setContent(String content) { this.content = content; } public void speakHello(){ //how do i get value of laaala here which is in MasterBean??? content = ??? + " Hello friend"; } public pageBean() { } }
What should I put in the blank where
???
is marked in speakHello(). How do I get value of other bean in this bean?
原文:https://stackoverflow.com/questions/2779480
最满意答案
您不需要使用主输出或内容文件。 您只需将单个文件(或在IDE中添加它们)拖到文件系统视图中的所需文件夹中即可。 因此,对于您的文本文件,只需将其添加到(例如)CommonAppData或用户的个人数据文件夹中,然后您可以右键单击文本文件,创建快捷方式并将快捷方式拖动到用户的Dektop或任何您想要的位置。
You don't need to use either Primary Output or Content Files. You can just drag the individual files (or add them in the IDE) into the required folder in the File System view. So, for your text file, just add it into (say) the CommonAppData or User's Personal Data folder, then you can right-click on the text file, create shortcut and drag the shortcut to User's Dektop or wherever you want it.
相关问答
更多-
在linux系统中 启动配置网卡的界面用什么命令[2022-02-09]
setup -
右键单击项目,选择添加>现有项目,然后在对话框中下拉添加按钮,然后选择添加为链接。 Right-click the project, select Add > Existing Item, and in the dialog drop down the Add button and select Add As Link.
-
WIX - 为文件系统上的现有文件创建桌面快捷方式(WIX - Creating Shortcut to desktop for an existing file on the filesystem)[2023-06-23]
Shortcut / @ Target属性已格式化。 这意味着您可以使用“[PROPERTY_ID]”语法通过属性提供路径。 FileSearch元素可用于查找要指向的可执行文件并将其分配给Property。 命令行参数可通过Shortcut / @ Arguments属性提供。 The Shortcut/@Target attribute is formatted. That means you can provide a path in via a Property using the "[PROPER ... -
我也有这个麻烦 在添加快捷方式之前,尝试一次重建您的项目 “项目输出”的图标将会改变,并且您将无法再添加快捷方式。 如果在构建之前添加快捷方式,则会出现目标在构建时无效的错误(并且项目输出的图标也会更改)。 Im having trouble with this also Try to rebuild your project one time before you add the shortcuts the "project output"'s icon will change, and you wont ...
-
安装项目放置特殊类型的快捷方式。 它不会简单地启动你的程序。 它首先检查随程序一起安装的所有文件。 如果他们这样做,它会启动程序,如果他们不安装程序再次从msi缓存运行重新安装缺少的文件。 您是否有安装后的操作来删除一些已安装的文件? ok, I found the problem. The error is in the code of the custom installer class: Process.Start(Path.Combine(Directory.GetCurrentDirectory( ...
-
问题是你不包括安装程序中包含图标的实际ico,exe或dll文件? 快捷方式文件(.lnk)实际上并不包含图标的副本,只是指向它们的链接。 So was the problem you were not including the actual ico, exe or dll file containing the icon in the installer? shortcut files (.lnk) do not actually contain a copy of the icon, just a l ...
-
我刚刚通过将构建模式从Debug更改为Release来解决了这个问题。 主要输出...(版本x86) - 它正在寻找x86的发布版本。 I just solved this by changing my build mode from Debug to Release. Primary Output for ... (Release x86) - It is looking for a release build of x86.
-
Visual Studio安装项目 - 创建exe文件的快捷方式(Visual Studio Setup Project - Create shortcut of exe file)[2022-05-13]
如果您创建窗口设置项目...然后它显示图标是Advertisement而不是快捷方式链接..然后您创建一个Exe的快捷方式然后...它创建一个快捷方式链接... 这些快捷方式称为广告快捷方式。 他们将提供按需安装和广告的应用程序能力。 当用户单击此类快捷方式时,Windows Installer将检查应用程序的完整性并自动安装/修复丢失或损坏的组件。 要禁用公布的快捷方式,必须在MSI包中将名为DISABLEADVTSHORTCUTS的属性设置为值1。 http://msdn.microsoft.com/e ... -
您不需要使用主输出或内容文件。 您只需将单个文件(或在IDE中添加它们)拖到文件系统视图中的所需文件夹中即可。 因此,对于您的文本文件,只需将其添加到(例如)CommonAppData或用户的个人数据文件夹中,然后您可以右键单击文本文件,创建快捷方式并将快捷方式拖动到用户的Dektop或任何您想要的位置。 You don't need to use either Primary Output or Content Files. You can just drag the individual files ( ...
-
你可以使用os.path.islink() import os pathInput = os.path.abspath(input('Enter the path for the directory to search ')) for folder, subFolders, files in os.walk(pathInput): for file in files: if not os.path.islink(file): # rest of code ...