我正在使用Django 1.3 alpha创建一个包含两个应用程序的项目.我使用1.3是因为基于类的视图.对于这两个应用程序,我有一组公共基本视图类,它们由应用程序中的实际视图继承.在基类中,有没有办法找出视图被"调用"的应用程序?例如,我可以使用URL来获取"当前"应用程序吗?
我有以下代码:
List<string> aa = (from char c in source
select new { Data = c.ToString() }).ToList();
Run Code Online (Sandbox Code Playgroud)
但是关于
List<string> aa = (from char c1 in source
from char c2 in source
select new { Data = string.Concat(c1, ".", c2)).ToList<string>();
Run Code Online (Sandbox Code Playgroud)
编译时收到错误
无法隐式转换
'System.Collections.Generic.List<AnonymousType#1>'为'System.Collections.Generic.List<string>'
需要帮忙.
我的可绘制文件夹中有100多张图像(国家标志)的数据库.
现在,我想在ImageView中显示您当前所在国家/地区的标志.
我和国家在一起 String country_variable = address.getCountryCode();
我用图像设置了图像 flag.setImageDrawable(getResources().getDrawable(R.drawable.country_variable));
众所周知,R.drawable.country_variable不起作用,因为编译器无法在drawable文件夹中找到名为country_variable的图像.
做这个的最好方式是什么?
我正在尝试遍历页面上的所有元素,所以我想检查此页面上存在的每个元素是否有特殊类.
那么,我怎么说我想检查每个元素?
运行这个:
class DontList(object):
def __getitem__(self, key):
print 'Getting item %s' % key
if key == 10: raise KeyError("You get the idea.")
return None
def __getattr__(self, name):
print 'Getting attr %s' % name
return None
list(DontList())
Run Code Online (Sandbox Code Playgroud)
产生这个:
Getting attr __length_hint__
Getting item 0
Getting item 1
Getting item 2
Getting item 3
Getting item 4
Getting item 5
Getting item 6
Getting item 7
Getting item 8
Getting item 9
Getting item 10
Traceback (most recent call last):
File "list.py", line …Run Code Online (Sandbox Code Playgroud) 我希望能够抓住应用程序的主要UIView.到目前为止,我一直在调用[[[self.view superview] superview] superview]来遍历链(或者向下,取决于你如何看待它).这个问题是我可能无法完全确定我需要达到的级别数.有办法:
或者,如果没有,
我解析了HTML代码org.w3c.dom.Document.我需要检查所有标记style属性,解析它们,更改一些CSS属性并将修改后的样式定义返回到属性.
是否有任何标准方法来解析style属性?如何使用org.w3c.dom.css包中的类和接口?
我需要一个Java解决方案.
我有一个非常简单的jQuery手风琴,每个标题内都有单选按钮.
看到这个JSFiddle
当我选择一个单选按钮时,它应该被检查,手风琴应该在该位置打开.奇怪的问题是手风琴打开但收音机没有被检查.
对我来说这看起来像jQuery-ui中的一个bug,任何帮助都会受到赞赏.
<div class="accordion">
<h3>
test1
<input type="radio" checked="checked" name="radio" />
</h3>
<div>
content<br />
content<br />
content<br />
content<br />
</div>
<h3>
test2
<input type="radio" name="radio" />
</h3>
<div>
content<br />
content<br />
content<br />
content<br />
</div>
<h3>
test3
<input type="radio" name="radio" />
</h3>
<div>
content<br />
content<br />
content<br />
content<br />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
$(".accordion").accordion()
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样简单,它可以得到......
我正在使用EclipseLink作为JPA提供程序.此外,我正在使用以下TABLE_PER_CLASS继承结构
@javax.persistence.Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries({
@NamedQuery(name=Parent.QUERY_FIND_ALL, query="SELECT p FROM Parent p")
})
public class Parent {
// the class code follows here
}
@javax.persistence.Entity
@NamedQueries({
@NamedQuery(name=Child.QUERY_FIND_ALL, query="SELECT c FROM Child c")
})
public class Child extends Parent {
// the class code follows here
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是我只想接收父类的条目.但是使用命名查询"SELECT p FROM Parent p",也会返回子表中的所有条目.
选择或查找代码如下:
public List findWithNamedQuery(String query) {
return em.createNamedQuery(query).getResultList();
}
Run Code Online (Sandbox Code Playgroud)
因此查询即"SELECT p FROM Parent p".
我怎样才能真正接收父条目而不是这个inheritacne层次结构的所有条目?
简而言之:如何保持所有子条目不受影响,并仅返回父条目?
编辑1:
我正在使用EclipseLink 2.0.1,但每次我通过类型表达式尝试axtavt的解决方案时,我都会收到以下错误:
"Invalid Type Expression on [my.domain.Parent]. The class does not have …Run Code Online (Sandbox Code Playgroud)