我的应用程序中需要一个类似日历应用程序的UI组件.我的意思是,不一定像日历应用程序那样漂亮和复杂,但足够接近.
是否有类似的东西可能是开源的?框架,API,库,代码段等?
(我故意说iPad而不是iPhone!我知道iPhone有很好的解决方案)
你能找到一个关于在Google App Engine Objectify世界中实现良好分页的好教程或文档吗?
我找到了一些帖子:http: //groups.google.com/group/objectify-appengine/browse_thread/thread/b640b5d377b620b4
但似乎没有什么能帮助我.有某种LIMIT查询吗?
不幸的是,我有一个包含值的字段列
我要编写一个SELECT语句,其结果如下:
我怎么能在实践中做到这一点,因为MySQL不提供"拆分"功能?
我有一个名为"父亲"的简单POJO和另一个名为"Son"的人,它扩展了"父亲",这是最简单的类继承示例.
现在我有一个List<Son>,我需要把它投到一个List<Father>.
我能怎么做?
编辑
抱歉命名错误,我没有解释自己.人与职工会是一个更好的例子.或者产品和计算机.
我有一个品牌实体的模型映射:
@Entity
public class Brand implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private BrandPk id;
//...
}
Run Code Online (Sandbox Code Playgroud)
复合键为:
@Embeddable
public class BrandPk implements Serializable {
private static final long serialVersionUID = 1L;
private int id1;
private int id2;
//...
}
Run Code Online (Sandbox Code Playgroud)
现在我想加入一个产品实体(一个品牌,多种产品):
我会有:
@Entity
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@ManyToOne
// ???
private Brand brand;
//...
}
Run Code Online (Sandbox Code Playgroud)
我需要什么才能正确连接我的表实体?
table_brands有一个由两个字段组成的 PK:id1 …
我刚刚将我们的一个核心应用程序从Windows + IIS + Coldfusion移动到Ubuntu + Apache + Lucee.第一个大问题是异域字母表的URI编码.
例如,尝试访问此URL会http://www.example.com/ru/??????????????-????/saint-laurent/导致Apache access.log中的此记录:
http://www.example.com/ru/%D0%A1%D0%BE%D0%BB%D0%BD%D1%86%D0%B5%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%BD%D1%8B%D0%B5-%D0%BE%D1%87%D0%BA%D0%B8/saint-laurent/
Run Code Online (Sandbox Code Playgroud)
好吧,我认为这是正确的网址编码.然后我在.htaccess文件中使用重写规则来获取url查询字符串参数中的url(西里尔文本)部分(让我们说"foo").
使用cflog来转储它,我在应用程序日志中看到:
/index.cfm?foo=оÑки-длÑ-зÑениÑ&
Run Code Online (Sandbox Code Playgroud)
...这显然是错误的,因为我需要的是原始字符串,在utf-8西里尔字母中.
我试图将URIEncoding参数放在我的server.xml tomcat http连接器中,没有结果:
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
Run Code Online (Sandbox Code Playgroud)
如何以UTF-8获取我的url参数?
我有一个简单的类 Foo:
class Foo {
String type;
Integer quantity;
String code;
//...
}
Run Code Online (Sandbox Code Playgroud)
以及该类型的对象列表:
{ type=11, quantity=1, code=A },
{ type=11, quantity=2, code=A },
{ type=11, quantity=1, code=B },
{ type=11, quantity=3, code=C },
{ type=12, quantity=2, code=A },
{ type=12, quantity=1, code=B },
{ type=11, quantity=1, code=B },
{ type=13, quantity=1, code=C },
{ type=13, quantity=3, code=C }
Run Code Online (Sandbox Code Playgroud)
我需要先按类型分组,我可以这样做:
Map<String, List<Foo>> typeGroups = mylist.stream().collect(Collectors.groupingBy(Foo::getType));
Run Code Online (Sandbox Code Playgroud)
下一步是将其转换Map为List<Foo>这样的:
{ type=11, quantity=3, code=A },
{ type=11, quantity=2, code=B }, …Run Code Online (Sandbox Code Playgroud) 我需要更新文档值,"切换"它:
该集合是"Comment",其具有布尔标志"isAdmin".
我要更新给定的注释ID,如果是真的则将isAdmin设置为false,反之亦然.
但是这不起作用:
db.comments.update( { "id": "xxx" }, { $set: { isAdmin: $not isAdmin } } );
Run Code Online (Sandbox Code Playgroud)
什么是正确的语法?
我想使用"name + surname"字符串作为键来查询我的"customers"表.
姓名和姓氏存储在不同的字段中.
所以我的查询是:
SELECT
*
FROM
customers
WHERE
CONCAT(name,' ',surname) LIKE '%term%'
OR CONCAT(surname,' ',name) LIKE '%term%'
Run Code Online (Sandbox Code Playgroud)
但是,我不能这样做,我的查询是JPA2 条件查询.就像是:
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery();
Root<Customer> from = cq.from(Customer.class);
cq.select(from);
Predicate whereClause = cb.or(
cb.like(from.<String>get("name"), "%"+ r +"%"),
cb.like(from.<String>get("surname"), "%"+ r +"%"),
);
cq.where(whereClause);
TypedQuery<Customer> query = getEntityManager().createQuery(cq);
list = query.getResultList();
Run Code Online (Sandbox Code Playgroud)
如何通过姓名和姓氏的组合过滤我的结果集,好吗?
我知道在Web应用程序中使用有状态与无状态EJB存在很多争议.
购物车是最常见的用例:Oracle的Java EE示例也在官方文档中使用了很多.
在stackoverflow上,我发现了许多有趣的答案,例如JavaEE中的购物车困境,经常会说:
好的... SFSB在企业,复杂的场景中很好,例如,如果你想与其他应用程序共享它们,并使它们不仅可用于JSF/web客户端
但是......如果你只是在开发爷爷的电子商务网站,只需坚持使用HttpSession/SessionScoped cdi-managed bean,并在SLSB中编写业务方法,因为它们更有效,等等......
但是,因为我还处于学习和发现阶段,所以我只想尝试自己试图建立一个简单的购物车.
我看到了一个有趣的教程,建议在HttpSession中存储一个JNDI检索的@Stateful购物车ejb接口实例,这是Web客户端第一次需要它,然后在网络会话期间像往常一样使用它.在我的JSF表示层中,我想我会有一个@SessionScoped @Named bean(让我们称之为ShopController),并且在其初始化中,将一个有状态ejb实例存储在一个实例变量中.
我想知道是否可以通过使用@SessionScoped CDI注释将@Stateful bean直接绑定到http会话.
它会如上所述起作用吗?CDI会为每个网络会话创建一个SFSB吗?