小编Aka*_*ash的帖子

AutoComplete Material-ui React getOptionSelected 道具不起作用

我对反应还很陌生,并且非常感谢这里的一些指示:

我有一个带有某些选项集的自动完成下拉菜单。我希望根据我的条件默认选择其中之一。

据我了解,这可以通过自动完成中的getOptionSelected 属性来完成。

我创建了一个示例来测试这一点,但是这并没有按预期工作。你能帮忙吗?

代码沙箱在这里

/* eslint-disable no-use-before-define */
import React from "react";
import TextField from "@material-ui/core/TextField";
import Autocomplete from "@material-ui/lab/Autocomplete";

export default function ComboBox() {
  return (
    <Autocomplete
      id="combo-box-demo"
      options={top100Films}
      getOptionLabel={(option: { title: string; year: number }) => option.title}
      getOptionSelected={(option) => option.year === 1994}
      style={{ width: 300 }}
      renderInput={(params) => (
        <TextField {...params} label="Combo box" variant="outlined" />
      )}
    />
  );
}

// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
const top100Films = [
  { title: …
Run Code Online (Sandbox Code Playgroud)

autocomplete reactjs react-native material-ui

7
推荐指数
1
解决办法
1万
查看次数

同一实体的多个表示正在合并、分离

我在尝试使用 jpa2.0 将包含持久实体和分离实体(新创建的实体)的实体列表更新到我的数据库中时遇到错误。我的实体包含在合并数据时出现错误(在标题中提到)的内部实体:

Class superclass{
    private A a;
    private string name;

    //getter setters here...
}

Class A{
    private long id;
    @onetoone(cascade=CascadeType.All, fetch=FetchType.Eager)
     private B b;
    @onetoone(cascade=CascadeType.All, fetch=FetchType.Eager)
    private C c;

    //getter setters here...

}


Class Dao{

    daoInsert(superclass x){

    em.merge(x);

       }
}
Run Code Online (Sandbox Code Playgroud)

我希望发送的任何实体都可以合并到数据库中。

Hibernate 通过将以下内容添加到persistence.xml 确实为此提供了解决方案

我可以在 jpa 中做一些与 hibernate.js 相同的事情吗?

请不要建议使用 em.find() 查找实体然后手动更新,因为我也需要实体、持久化实体和新创建的实体。此外,我正在使用弹簧形式将整个专利实体保存到数据库中。

如果我不够清楚,我很抱歉,这是我的第一个问题,我真的是初学者。

任何帮助将不胜感激。

jpa jpa-2.0

3
推荐指数
1
解决办法
3万
查看次数

openapi 3.0 中所有 API 的强制性标头

我在 Spring-boot 5 中使用 OpenAPI 3.0,因此没有配置 YAML。我有一个包含客户端标识 ID 的标头(这不是身份验证标头)。我想让它成为一个强制性的标题参数。在 OpenAPI 配置下方添加

@Configuration
public class OpenAPIConfiguration {
    @Bean
    public OpenAPI customOpenAPI() {

        return new OpenAPI()
                .components(new Components()
                        .addParameters("myCustomHeader", new Parameter().in("header").schema(new StringSchema()).required(true).description("myCustomHeader").name("myCustomHeader")))
                .info(new Info()
                        .title("My Rest Application")
                        .version("1.2.26"));
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,swagger UI 不会在任何 API 中显示所需的参数。有人可以帮助我做错什么吗?

在此处输入图片说明

swagger swagger-ui spring-boot openapi swagger-3.0

1
推荐指数
1
解决办法
3391
查看次数