SelectBooleAnCheckboxレンダリングされた状態は、バッキングビーンと一致しません
-
29-10-2019 - |
質問
JSF2.0を使用しており、ウィザードを構築しています。 SelectBooleanCheckboxesで問題に遭遇しました。これがワークフローです:
- チェックボックスを使用してページを読み込みます(値は、バッキングビーンのsortedmapにバインドされています)。
- それらをチェックして、[次へ]をクリックします。これにより、ページが使用するカーソルが増加し、負荷のパネルグループが決定されます。
- (正しい)値は豆に持続します。
- バックバック(カーソルが減少している)をクリックし、ページに編集可能なチェックボックスをレンダリングします。最初のチェックボックスはチェックされていません(バウンド変数にそのボックスの値の値が保持されていても)。
このカーソルベースのアプローチ(すべてのウィザード画面を含む)は機能しないようです。ただし、これをわずかに変更して、前/次のボタンが異なるXHTMLページを表示するようにすると、この問題は消えます。
残念ながら、私はこれをすることができません。このウィザードをモーダルダイアログに差し込むので、Prev/Nextの新しいページにアクセスすると機能しません
私はこの小さな例を書きました(魔法使い全体を歩き回るように頼むのではなく)。
これがJavaクラスです:
@ConversationScoped
@Named("hashBool")
public class HashBoolTest2 implements Serializable {
private static final long serialVersionUID = 1962031429874426411L;
@Inject private Conversation conversation;
private List<RestrictionItem> list;
private SortedMap<String, Boolean> values;
private int cursor;
public HashBoolTest2( ) {
List<String> none = new ArrayList<String>();
none.add("");
this.setList( new ArrayList< RestrictionItem >( ) );
this.getList().add( new RestrictionItem( "a", "a", none ) );
...
this.getList().add( new RestrictionItem( "e", "e", none ) );
this.setValues( new TreeMap< String, Boolean >() );
this.setCursor( 0 );
}
@PostConstruct
public void andThis() {
this.conversation.begin( );
}
// getters and setters for instance variables
@Override
public String toString() {
return "Values : " + this.values.toString( ) + " List: " + this.list.toString( );
}
public void kill() {
this.conversation.end( );
}
public void doNext(ActionEvent e) {
this.cursor++;
}
public void doPrev(ActionEvent e) {
this.cursor--;
}
}
XHTMLフラグメントは次のとおりです。
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>IGNORED</title>
</head>
<body>
<ui:composition>
<h:panelGroup id="container">
<h:form>
<!-- edit state -->
<h:panelGroup id="edit" rendered="#{hashBool.cursor eq 0}">
<code>
<h:outputText value="#{hashBool.toString()}" escape="false"/>
</code>
<ul>
<ui:repeat value="#{hashBool.list}" var="elem">
<li>
<h:selectBooleanCheckbox id="elem" value="#{hashBool.values[elem.id]}" title="#{elem.displayName}" />
<h:outputLabel for="elem" value="#{elem.displayName}"/>
</li>
</ui:repeat>
</ul>
</h:panelGroup>
<!-- view state -->
<h:panelGroup id="view" rendered="#{hashBool.cursor eq 1}">
<code>
<h:outputText value="#{hashBool.toString()}" escape="false"/>
</code>
</h:panelGroup>
<br/>
<!-- buttons -->
<h:panelGroup id="buttons">
<f:ajax render=":container">
<h:commandButton value="Prev" actionListener="#{hashBool.doPrev}"/>
<h:commandButton value="Next" actionListener="#{hashBool.doNext}"/>
</f:ajax>
<h:commandButton value="Kill" actionListener="#{hashBool.kill()}"/>
</h:panelGroup>
</h:form>
</h:panelGroup>
</ui:composition>
</body>
</html>
どんな提案も大歓迎です! (そして、これが二重の投稿である場合、申し訳ありませんが、ここで検索しているときに同様のものを明らかにすることができませんでした)
正しい解決策はありません
所属していません StackOverflow