这是我在xhtml中的代码和支持bean中的代码。如何设置项目标签ALL值以搜索所有值。
public class FaPrincipiaCntrprtyList extends
FaPrincipiaCntrprtyQuery<FaPrincipiaCntrprty> {
static Logger logger = Logger.getLogger(FaPrincipiaCntrprtyList.class.getName());
private static final long serialVersionUID = 1L;
private byte activeFlag = 1;
/*List<Byte> activeFlagList = new ArrayList<Byte>();
public List<Byte> getActiveFlagList() {
return activeFlagList;
}
public void setActiveFlagList(List<Byte> activeFlagList) {
this.activeFlagList = activeFlagList;
}*/
private static final String EJBQL = "select faPrincipiaCntrprty from FaPrincipiaCntrprty faPrincipiaCntrprty";
private static final String[] RESTRICTIONS = {"lower(faPrincipiaCntrprty.cntrprtyCode) like lower(concat(#{faPrincipiaCntrprtyList.faPrincipiaCntrprty.cntrprtyCode},'%'))",
"faPrincipiaCntrprty.activeFlag = #{faPrincipiaCntrprtyList.activeFlag}",};
private FaPrincipiaCntrprty faPrincipiaCntrprty = new FaPrincipiaCntrprty();
public FaPrincipiaCntrprtyList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(10);
}
public byte getActiveFlag() {
return activeFlag;
}
public void setActiveFlag(byte activeFlag) {
if (activeFlag == 2) {
activeFlag = (Byte) null;
}
/*if (activeFlag == 2) {
activeFlagList.add((byte) 0);
activeFlagList.add((byte) 1);
setActiveFlagList(activeFlagList);
}else{
activeFlagList.add((byte) activeFlag);
setActiveFlagList(activeFlagList);
}*/
this.activeFlag = activeFlag;
}
public FaPrincipiaCntrprty getFaPrincipiaCntrprty() {
return faPrincipiaCntrprty;
}
}
以下是支持豆
<Window x:Class="HTML_Viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="HTML Viewer" Height="350" Width="525">
<Grid Name="grid_Main">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Menu Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="0">
<MenuItem Header="File">
<MenuItem Header="Open HTML File"/>
<Separator/>
<MenuItem Header="Save"/>
<Separator/>
</MenuItem>
<ToolBar Width="Auto">
<Button x:Name="btnLocal" BorderBrush="DarkGray" Content="Load Local" Click="btnLocal_Click" Width="67"
HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Panel.ZIndex="1"
Margin="0,0,0,-1" Height="22"/>
<Button x:Name="btnCodeView" BorderBrush="DarkGray" Content="Code View" Click="btnCodeView_Click" Width="67"
HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Panel.ZIndex="1"
Height="Auto" Margin="0,0,0,-1"/>
<Button x:Name="btnPageView" BorderBrush="DarkGray" Content="Page View" Click="btnPageView_Click" Width="67"
HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Panel.ZIndex="1"
Height="Auto" Margin="0,0,0,-1"/>
<Button x:Name="btnSplitView" BorderBrush="DarkGray" Content="Split View" Click="btnSplitView_Click" Width="67"
HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Panel.ZIndex="1"
Height="Auto" Margin="0,0,0,-1"/>
</ToolBar>
</Menu>
<Grid Name="innerGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="col1" Width="*"/>
<ColumnDefinition Name="col2" Width="*"/>
</Grid.ColumnDefinitions>
<WebBrowser x:Name="webOutput" Width="{Binding ElementName=col1,Path=ActualWidth}"
Height="{Binding ElementName=col1, Path=ActualHeight}"/>
<TextBox x:Name="txtInput" Background="Bisque" Grid.Column="1" Width="{Binding ElementName=col2,Path=ActualWidth}"
Height="{Binding ElementName=col2, Path=ActualHeight}" />
</Grid>
</Grid>
</Window>
答案 0 :(得分:0)
您可以将任何值设置为selectAll
。最终,您将匹配确切的值并获取所有记录。
让我们说,我已将其分配给值2,
<强> XHTML 强>
<h:form>
<h:selectOneRadio value="#{faPrincipiaCntrprtyList.activeFlag}">
<f:selectItem itemLabel="Active" itemValue="1"/>
<f:selectItem itemLabel="InActive" itemValue="0" />
<f:selectItem itemLabel="All" itemValue="2"/>
<f:ajax listener="#{faPrincipiaCntrprtyList.processFlagSelection()}" render=":searchResult"/>
</h:selectOneRadio>
</h:form>
<h:panelGroup id="searchResult">
#{faPrincipiaCntrprtyList.searchResult}
</h:panelGroup>
<强>豆强>
@ManagedBean
@ViewScoped
public class FaPrincipiaCntrprtyList {
private long activeFlag = 0;
private String searchResult;
public void processFlagSelection() {
if (activeFlag == 2) {
searchResult = "Featch all result from database.";
} else {
searchResult = "Fetch result based on active/inactive";
}
}
//getter and setters
}
注意:这仅用于演示。根据您的需要更改searchResult
类型。