小编Syd*_*ney的帖子

jquery插件调用其他公共函数内的public函数

我在http://docs.jquery.com/Plugins/Authoring上定义了我的插件

(function( $ ){

  var methods = {
    init : function( options ) {  },
    show : function( options ) {  },
    hide : function( ) {  },
    update : function( content ) { 
      // How to call the show method inside the update method
      // I tried these but it does not work
      // Error: not a function
      this.show(); 
      var arguments = { param: param };
      var method = 'show';
      // Error: options is undefined
      methods[ method …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-plugins

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

Java泛型类型不匹配

我有一个抽象类定义为:

public abstract class TCV<T extends MF> {
    public Map<String, MVR<T>> operation() {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

主要代码:

TCV<? extends MF> o = new TCVConcrete();
Map<String, MVR< ? extends MF>> map = o.operation();
Run Code Online (Sandbox Code Playgroud)

日食错误:

Type mismatch: cannot convert from Map<String,MVR<capture#5-of ? extends MF>> to Map<String,MVR<? extends MF>>

编辑

public class TCVConcrete extends TCV<MFV2> {
}

public class MFV2 extends MF {
}
Run Code Online (Sandbox Code Playgroud)

java generics

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

maven配置文件激活基于几个文件的存在

我想根据几个文件的存在激活一个配置文件.在下面的例子中,我想配置文件将被激活,如果这两个文件my.markeranother.marker存在.

    <activation>
        <file>
            <exists>${basedir}/my.marker</exists>
            <exists>${basedir}/another.marker</exists>
        </file>
    </activation>
Run Code Online (Sandbox Code Playgroud)

它不起作用,因为它对模式无效.有没有办法在不使用命令行属性的情况下做这样的事情?

maven

5
推荐指数
2
解决办法
2972
查看次数

JSF 2.0注入具有不同范围的托管bean

我有一个无状态的控制器,负责处理表格.这被定义为ApplicationScoped.在我的页面上,我有一个与支持bean关联的表单定义为a ViewScoped.

我想处理表单时遇到的错误:

serverError: class com.sun.faces.mgbean.ManagedBeanCreationException Unable to create managed bean myController.  The following problems were found:
     - The scope of the object referenced by expression #{myFormBean}, view, is shorter than the referring managed beans (myController) scope of application
Run Code Online (Sandbox Code Playgroud)

在我的形式:

       Name: <h:inputText value="#{myFormBean.name}" id="name" />
        <h:commandButton value="Save Name" action="#{myController.processForm}">
            <f:ajax render="nameResult" />
        </h:commandButton>
       Your name is <h:outputText value="#{myFormBean.name}" id="nameResult"/>
Run Code Online (Sandbox Code Playgroud)

控制器:

@ManagedBean
@ApplicationScoped
public class MyController {
    @ManagedProperty("#{myFormBean}")
    private MyFormBean myBean;
    public void processForm() {
        System.out.println(myBean.getName());
        // Save …
Run Code Online (Sandbox Code Playgroud)

jsf jsf-2

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

XSD循环导入

我需要解析一个XSD,XSOM但这个XSD包含循环导入.

A.xsd

<xs:schema xmlns=”ns1” targetNamespace=”ns1”>
  <xs:import namespace=”ns2” schemaLocation=”B.xsd”/>
  <xs:element name=”MyElement” type=”xs:string”/>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

B.xsd

<xs:schema xmlns=”ns2” targetNamespace=”ns2” xmlns:ns1=”ns1”>
  <xs:import namespace=”ns1” schemaLocation=”A.xsd”/>
  <xs:complexType name="MyComplex">
    <xs:sequence>
      <xs:element ref="ns1:MyElement" minOccurs="0"/>
    <xs:sequence>
  <xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

XSOM无法解析模式,因为它检测到由于循环导入而已定义的元素.所以我试图通过外化由A定义并在B中使用的元素来打破循环导入.

C.xsd包含A使用的元素B.请注意,这些元素不在A中使用.不要问我为什么在A中定义了这些元素.

<xs:schema xmlns=”ns1” targetNamespace=”ns1”>
  <xs:element name=”MyElement” type=”xs:string”/>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

A.xsd成了

<xs:schema xmlns=”ns1” targetNamespace=”ns1”>
  <xs:import namespace=”ns2” schemaLocation=”B.xsd”/>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

B.xsd(导入C.xsd而不是A.xsd)成为

<xs:schema xmlns=”ns2” targetNamespace=”ns2” xmlns:ns1=”ns1”>
  <xs:import namespace=”ns1” schemaLocation=”C.xsd”/>
  <xs:complexType name="MyComplex">
    <xs:sequence>
      <xs:element ref="ns1:MyElement" minOccurs="0"/>
    <xs:sequence>
  <xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

XSOM可以解析XSD.但现在我无法使用以下代码创建架构:

SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
sf.setResourceResolver(new MyResourceResolver());
Run Code Online (Sandbox Code Playgroud)

我使用与JDK 1.7捆绑在一起的标准实现.我得到了例外:

src-resolve: Cannot resolve the …
Run Code Online (Sandbox Code Playgroud)

java xsd xsom

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

使用requirejs timeout加载异步资源

我尝试使用requirejs和async插件加载适用于JavaScript的Google API客户端库:

require.config({
    paths : {
        async : '../lib/requirejs/async'
    },
    waitSeconds: 60
});

define('gapi', ['async!https://apis.google.com/js/client.js!callback'],
    function(){
        console.log('gapi loaded');
        return gapi.client;
    }
);

require(['gapi'], function(){
    console.log("Callback");
    console.log(gapi);
});
Run Code Online (Sandbox Code Playgroud)

加载此库的常用方法是

<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
Run Code Online (Sandbox Code Playgroud)

一切都在不到2秒内加载,但我总是得到这个错误:

Uncaught Error: Load timeout for modules: async!https://apis.google.com/js/client.js!callback_unnormalized2,async!https://apis.google.com/js/client.js!callback
http://requirejs.org/docs/errors.html#timeout 
Run Code Online (Sandbox Code Playgroud)

javascript requirejs

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

JSF 2.0 Primefaces关闭复合组件中的对话框

我想在对话框中显示复合组件.它工作但是如何从复合组件关闭该对话框.

<p:commandButton value="Display Data Value Assertion Dialog" onclick="dlg2.show();" type="button"/> 
<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="600" width="800">  
        <tcmt:DataValueAssertion managedBean="#{dataValueAssertionController}"/>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)

在我的复合组件中:

        <h:commandButton value="Save Assertions">
            <f:ajax listener="#{datatypeAssertionController.saveDatatypeAssertion}"></f:ajax>
        </h:commandButton>

        <h:commandLink value="Close">
            <f:ajax listener="#{datatypeAssertionController.closeDatatypeAssertion}"></f:ajax>
        </h:commandLink> 
Run Code Online (Sandbox Code Playgroud)

单击"保存"时,我希望能够保存数据并关闭对话框.单击取消时,我只想关闭对话框而不保存.两者saveDatatypeAssertioncloseDatatypeAssertion方法都是占位符.我需要找到一种方法来获取对话框的引用dlg2,然后hide()在其上调用方法.

jsf primefaces jsf-2

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

Hibernate HQL与IS NULL的奇怪行为

我有一个HQL查询的问题.我希望将管理性别设置为"M"或没有管理性的所有PID(在Java中将值设置为null).

PID.class

@Entity
@Table(name = "PatientIdentification")
public class PID {    

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "administrativeSex", referencedColumnName = "is_id")
    private IS administrativeSex;
    ...
}
Run Code Online (Sandbox Code Playgroud)

IS.class

@Entity
@Table(name = "CodedValueForUserDefinedTables")
public class IS {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "is_id")
    private Integer id;

    private String value;
    ...
}
Run Code Online (Sandbox Code Playgroud)

HQL查询

from PID where administrativeSex is null or administrativeSex.value = 'M'
Run Code Online (Sandbox Code Playgroud)

生成的SQL

select
  pid0_.pid_id as pid1_84_,
  pid0_.administrativeSex as adminis11_84_,
  pid0_.birthOrder as birthOrder84_,
  pid0_.birthPlace as birthPlace84_,
  pid0_.citizenship as citizen12_84_,
  pid0_.countyCode as countyCode84_,
  pid0_.dateTimeOfBirth …
Run Code Online (Sandbox Code Playgroud)

java hibernate hql

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

如何删除 instanceof 以调用正确的方法?

我有以下类层次结构:

public interface Message
public interface V2Message extends Message
public interface V3Message extends Message
Run Code Online (Sandbox Code Playgroud)

我定义了另一个接口来验证消息。

public interface Validation {
  boolean validate(Message message);
}
Run Code Online (Sandbox Code Playgroud)

实现的每个类都Validation可以处理 V2 和/或 V3 消息,因此在我的实现中,我必须区分要验证的消息类型,因为代码会有所不同。

public class MyValidation implements Validation {
  public boolean validate(Message message) {
    if(message instanceof V2Message) {
      return validateV2((V2Message)message);
    } else if (message instanceof V3Message) {
      return validateV3((V3Message)message);
    }
}
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法删除instanceof.

java

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

文本不会在表格内包装

我希望我的表格中的文字能够自动换行.约束是我无法更改HTML,因为它是由服务器生成的.

我创建了一个JSFiddle

万一它不工作:

<div style="width: 25%">
    <table class="af_selectManyCheckbox" id="pt1:r1:1:smc1" cellpadding="0" cellspacing="0" border="0">
        <tbody>
            <tr>
                <td class="af_selectManyCheckbox_label" valign="top"/>
                <td valign="top" class="AFContentCell" nowrap="">
                    <div class="af_selectManyCheckbox_content">
                        <div>
                            <span class="af_selectManyCheckbox_content-input">
                                <input class="af_selectManyCheckbox_native-input" type="checkbox" value="0"/>
                            </span>
                            <label class="af_selectManyCheckbox_item-text">It allows a component to partially refresh another component whose partialSubmit property is set to true.</label>
                        </div>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

css

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

标签 统计

java ×4

jsf ×2

jsf-2 ×2

css ×1

generics ×1

hibernate ×1

hql ×1

javascript ×1

jquery ×1

jquery-plugins ×1

maven ×1

primefaces ×1

requirejs ×1

xsd ×1

xsom ×1