我有一个a4j:commandButton应该根据Id将我重定向到适当的"编辑"页面,我希望将其作为参数传递,如下所示:
<h:commandButton action="/details.jsf?faces-redirect=true" value="details">
<f:attribute name="id" value="#{bean.id}" />
</h:commandButton>
Run Code Online (Sandbox Code Playgroud)
问题是,它不起作用.我也尝试用"f:param name ="id"value ="#{bean.id}""替换f:attribute,但它也失败了.我唯一能做的就是输出链接:
<h:outputLink value="/details.jsf">
link
<f:param name="id" value="#{bean.id}" />
</h:outputLink>
Run Code Online (Sandbox Code Playgroud)
但我对链接并不满意,所以有没有办法使commandButton工作?
哦,我还有一个bean,应该在重定向后获得"id":
@PostConstruct
public void init(){
id= resolve("id");
}
Run Code Online (Sandbox Code Playgroud) 如何在JSF中创建切换按钮?
基本上,我需要两个按钮“ in”和“ out”。它们本质上调用了相同的托管Bean,但是由于每次单击,都应禁用一个,而应启用另一个,反之亦然。如何才能做到这一点?我应该使用ajax功能吗?
我现在一直在努力解决这个问题......我想做一些非常简单的事情.我想在运行时创建多个命令按钮,然后使用一个过程处理这些命令按钮的事件.所以我构建了一个"withevents"类来处理自动化,但我的代码不起作用.当我运行Test()时,会创建CommandButton,但是当我点击它时...没有消息框响应......我找不到错误..请任何帮助都会很棒!!
类cTest
Public WithEvents Button As MSForms.CommandButton
Public Sub Button_Click()
s = MsgBox("Hello", vbOKOnly)
End Sub
Run Code Online (Sandbox Code Playgroud)
第1单元
Public TestCollection As Collection
Sub Test()
Set TestCollection = New Collection
Dim Btn As CommandButton
Dim OLEBtnObj As cTest
Set OLEBtnObj = New cTest
Set Btn = Sheet1.OLEObjects.Add(ClassType:="Forms.CommandButton.1", link:=False,_ DisplayAsIcon:=False, Left:=368.25, Top:=51, Width:=44.25, Height:=24).Object
Set OLEBtnObj.Button = Btn
TestCollection.Add Item:=OLEBtnObj
End Sub
Run Code Online (Sandbox Code Playgroud) 我有一个页面,动态地包含来自另一个页面的内容(这是通过bean中的方法完成的)
firstPage.xhtml
<ui:include src="#{managedBean.pageView}">
<ui:param name="method" value="#{managedBean.someAction}"/>
</ui:include>
Run Code Online (Sandbox Code Playgroud)
这会重定向到第二个页面,<ui:composition>其中包含commandButton.
secondPage.xhtml
<ui:composition>
..
..
<p:commandButton actionListener=#{method} value="Submit"/>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
ManagedBean
public String pageView(){
return "secondPage.xhtml";
}
public void someAction(){
*someAction*
}
Run Code Online (Sandbox Code Playgroud)
secondPage.xhtml中的commandButton不起作用.
任何帮助将不胜感激.
我在更改CommandButton. 在电子表格中,我将设计按钮添加为表单或 ActiveX。
然后在 VBA 中我尝试:
Activesheet.shapes("CommandButton1").visible = false
Run Code Online (Sandbox Code Playgroud)
这个工作得很好。
但后来我尝试:
Activesheet.shapes.Fill.ForeColor.RGB = RGB(220, 105, 0)
Run Code Online (Sandbox Code Playgroud)
它运行没有错误,但没有任何变化;颜色保持原样。
你能帮我解决这个问题吗?
我正在创建一些在 OutLook (2010) 中使用的用户表单。我想利用一些 Office 图标作为各种命令按钮上的图像。无论如何,我是否可以引用 Office 图标,以避免必须使用宏分发 *.ico 文件?
不确定是否可能,但我在我的大部分学校项目中使用bootstrap.我通常在管理面板中使用的一个设计属性是使用图标(edit = pencil,remove = cross,add = plus,...).
因此,为了呈现这些简单的按钮,我使用以下代码:
<a href="#" class="btn"><i class="icon-pencil"></i></a>
Run Code Online (Sandbox Code Playgroud)
在与JSF一起使用时我尝试使用:
<h:commandButton value="<i class='icon-delete icon-white'></i>" class="btn-danger" action="#{horseController.delete(item.id)}" />
Run Code Online (Sandbox Code Playgroud)
但似乎不允许在此错误消息中声明'<':
错误解析/admin/horses.xhtml:跟踪错误[第27行]与元素类型"null"关联的属性"value"的值不得包含"<"字符.
所以我的问题是:如何在commandButton中使用标签,在这种情况下使用图标?
当我使用PrimeFaces时 p:commandButton
<p:commandButton action=#{bean.action} />
Run Code Online (Sandbox Code Playgroud)
我没有看到输入的验证消息(默认消息h:或PrimeFaces 消息p:).例如
<f:validateRequired />
Run Code Online (Sandbox Code Playgroud)
当我使用默认命令按钮时
<h:commandButton action=#{bean.action} />
Run Code Online (Sandbox Code Playgroud)
我确实看到了验证.造成这种差异的原因是什么?
我正在使用Prime Faces 3.5和Mojarra 2.1.18
<h:form id="reliefhourheadcopy-form">
<h:panelGrid columns="1">
<h:outputText value="Kopiere Entlastungsstunden von" />
<h:outputText value="Semester: #{reliefHourHeadManagedBean.reliefHourHead.semester}" />
<h:outputText value="Jahr: #{reliefHourHeadManagedBean.reliefHourHead.year}" />
<h:outputText value="nach" />
</h:panelGrid>
<h:panelGrid columns="3">
<h:outputText value="Semester:" />
<p:selectOneMenu id="semester" value="#{reliefHourHeadManagedBean.semester}">
<f:selectItems value="#{reliefHourHeadManagedBean.semesterTypes}" />
</p:selectOneMenu>
<h:message for="semester" />
<h:outputText for="yearSpinner" value="Jahr:" />
<p:spinner id="yearSpinner" value="#{reliefHourHeadManagedBean.year}" maxlength="4" min="2000" max="2030" size="4">
<f:validateRequired />
<f:validateLongRange minimum="2000" maximum="2030" />
</p:spinner>
<h:message for="yearSpinner" />
</h:panelGrid> …Run Code Online (Sandbox Code Playgroud) 早上好,我在主要表面上应用样式表时遇到问题commandButton,按钮元素如下:
<p:commandButton value="Complains" styleClass="styleOrange"/>
Run Code Online (Sandbox Code Playgroud)
和样式表:
.styleOrange {
background-color: orange;
}
Run Code Online (Sandbox Code Playgroud)
css文件放在css文件夹下的resources文件夹中:
这是css文件的include语句:
<h:head>
<h:outputStylesheet name="/resources/css/style.css" library="css" />
</h:head>
Run Code Online (Sandbox Code Playgroud) 我有一个提交按钮.此提交按钮具有"操作"属性.但是这个action属性应该总是调用另一个函数(某种泛型).所以我想动态调用一个函数.这是因为我需要重用这个组件.我只是不知道action属性需要哪种Type(Method,String等?)以及如何正确引用想要的"BeanWithMethodToCall".
@Named
@SessionScoped
public class BeanWithMethodToCall{
@Inject
private BeanWhichIsCalledFromEL elBean;
public void methodToCall(){
//do something
}
public void someLogic(){
// here the wanted method is set on the bean which is later on called from el
elBean.setMethodToCall("methodToCall");
}
}
@Named
@SessionScoped
public class BeanWhichIsCalledFromEL{
// i don't know the correct type of this :S
private String method;
public void setMethodToCall(String method){
this.method = method;
}
// i don't know the correct return type of this :S
public String getMethodToExecute(){
//this …Run Code Online (Sandbox Code Playgroud)