我想将 TableViewCell 中的 CheckBox 绑定到 BooleanBinding。以下示例包含一个带有列name和isEffectiveRequired. 列中的复选框绑定到表达式:
isRequired.or(name.isEqualTo("X"))
因此,当需要行中的项目或名称为 X 时,该项目是“有效需要的”,则表达式应为真。不幸的是 CheckBox 没有反映变化。为了调试我添加一个文本框,显示nameProperty,requiredProperty和所计算的effectiveRequiredProperty。
有趣的是,当只返回 isRequiredProperty 而不是绑定时,复选框有效。
public ObservableBooleanValue effectiveRequiredProperty() {
// Bindings with this work:
// return isRequired;
// with this not
return isRequired.or(name.isEqualTo(SPECIAL_STRING));
}
Run Code Online (Sandbox Code Playgroud)
那么就 CheckBox 而言,Property 和 ObservableValue 之间有什么区别?
public class TableCellCBBinding extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
init(primaryStage);
primaryStage.show();
}
private void init(Stage primaryStage) …Run Code Online (Sandbox Code Playgroud) 我对Spring引导数据和使用hibernate的JPA有很奇怪的行为.在我的实体CookbookRecipe被持久化之前,它被发现了CookBookRepository#findAll().
public interface CookbookRecipeRepository extends ExtendedJpaRepository<CookbookRecipe, Long> {}
Run Code Online (Sandbox Code Playgroud)
.
public class ExtendedJpaRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements ExtendedJpaRepository<T, ID> {
// added a new helper method, but certainly not overridden findAll
}
Run Code Online (Sandbox Code Playgroud)
测试
@RunWith(SpringRunner.class)
@DataJpaTest
public class CookbookRepositoryIntegrationTest {
@Autowired
RecipeRepository recipeRepository;
@Autowired
CookbookRepository cookbookRepository;
@Autowired
CookbookRecipeRepository cookbookRecipeRepository;
@Test
public void WhenAddingSameAssociationAgain_ThenNoException() {
Recipe recipe = new Recipe();
recipe.setTitle("A Recipe");
recipe = recipeRepository.save(recipe);
Cookbook cookbook = new Cookbook();
cookbook.setTitle("A Cookbook");
cookbook = cookbookRepository.save(cookbook);
cookbook.addRecipe(recipe, "integrationtest", …Run Code Online (Sandbox Code Playgroud)