小编Bas*_*sit的帖子

何时何地将javascript放入html中

我是Java脚本的新手.我正在练习code.When我把我的代码放在head部分,然后我得到元素null,当我把它放在body中,但在元素之前,然后我也得到null,但如果我把它放在body中,但是在元素之后然后我得到了元素.我想问一下为什么在前两种情况下我得到null.这是我的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <script type="text/javascript" src="js/attributes.js"></script>   // null

    </head>
    <body>

        <script type="text/javascript" src="js/attributes.js"></script>  // null
        <a id="braingialink"
           onclick="return showAttributes();"
           href="http://www.braingia.org" >Steve Suehring's Web Site
        </a>

        <script type="text/javascript" src="js/attributes.js"></script>   // ok

</body>
Run Code Online (Sandbox Code Playgroud)

这是我的javascript

var a1 = document.getElementById("braingialink");     //get null in first two cases
window.alert(a1.getAttribute("href"));
a1.setAttribute("href", "www.google.com");
window.alert(a1.getAttribute("href"));

function showAttributes() {

    var e = document.getElementById("braingialink");
    var elementList = "";

    for (var element in e) {

        /**
         * Sometimes, especially when …
Run Code Online (Sandbox Code Playgroud)

javascript

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

如何在JSF 2.0中使用CDI的视图范围

我在Netbeans 6.9中创建了一个JSF 2.0项目.我开始使用CDI了.在我尝试添加范围创建项目后,我注意到它中没有viewcope.我想知道对话范围和视图范围是指同样的事情吗?我可以使用会话范围代替视图范围.如果不是那么我如何将视图范围与CDI一起使用.我也知道缝是解决方案,但我怎么能用netbeans缝.是否有任何netbeans插件接缝?接缝-3-

谢谢

seam netbeans-plugins jsf-2 netbeans-6.9

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

如何使p:graphicImage可单击并调用bean动作

我使用<p:graphicImage>如下:

<div id="mapp">
    <h3>Country Map</h3>         
    <p:graphicImage id="city"
                    value="#{countryPages_Setup.countryMap}"
                    width="250"
                    height="190">

     </p:graphicImage>                
</div>
Run Code Online (Sandbox Code Playgroud)

但这不是可点击的图像.如何使这个图像可以点击,以便当用户点击它时,我可以调用我想要的托管bean动作.

jsf clickable primefaces graphicimage

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

如何让键盘选项卡专注于div

我做了一个消息框,上面有两个按钮.基本上它是一个jQuery插件,具有叠加效果的弹出窗口.但是当出现消息框,并且用户按下选项卡按钮时,消息对话框不会聚焦.那么我怎么能这样做呢,如果我的消息框出现,然后焦点自动转到我的消息框?当焦点丢失并且用户再次按下标签按钮然后它再次回到我的消息拨号如果我用鼠标单击消息框然后按标签按钮,然后焦点到达按钮然后消失.这是图像在此输入图像描述.这是制作盒子的代码.

var containerDiv = $("<div></div>", {
    id: config.containerDivID   
}); 

// append all the div to main Div(container)
containerDiv.append(messageDiv, buttonDiv);

centerPopup(config, containerDiv);
loadPopup(config);

function centerPopup(config, container){
    var backgroundPopup = $("<div></div>", {
        id: "backgroundPopup"
    }); //end of  imageDiv   
    $("body").append(backgroundPopup);
    $("body").append(container);
    $("#backgroundPopup").css({
        "height": windowHeight
    });
} //end of  centerPopup()

function loadPopup(config){
    //loads popup only if it is disabled
    if(popupStatus==0){
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#" + config.containerDivID).fadeIn("slow");
        popupStatus = 1;
   }  //end of if
} //end of function loadPopup()
Run Code Online (Sandbox Code Playgroud)

谢谢

jquery jquery-plugins

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

如何查找具有特定属性及其值的标签

我有这样的页面布局

<input id="name" class="mandotary" type="text">
<label for="name">Name must be entered</label>

<input id="code" class="mandotary" type="text">
<label for="code">Code must be entered</label>
Run Code Online (Sandbox Code Playgroud)

现在我想首先加载页面时隐藏标签元素.如果失去焦点且值为null,则应显示标签,否则应隐藏标签.我试过这个

var inputElementArray = $("input.mandotary");
$.each(inputElementArray, function(index, element){

    var id = $(element).attr("id");
    var label = $("label").attr("for", id);
   // label.hide();

    $(element).focus(function(){
        var next = $(element).next();
        $(element).next().hide();
    }); //end of focus()

    $(element).blur(function(){

        // get value of text area
        var text = $(element).val();
        if (text == "") {
            var next = $(element).next();
            $(element).next().show();
        } //end of if

    }); //end of blur()

}); //end of …
Run Code Online (Sandbox Code Playgroud)

jquery

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

如何从Glass Fish 3.1.2中的虚拟服务器中删除Web模块

我开发了一个Web服务。当我想在服务器上发布它时,出现以下错误

cannot Deploy TemperatureConverterServiceClientEAR
Deployment Error for module: TemperatureConverterServiceClientEAR: Error occurred
during  deployment: Exception while loading the app : java.lang.Exception: WEB0113:
Virtual server [server] already has a web module 
[AndroidBackendAuthentication.war] loaded at [/AndroidBackendAuthentication]; 
therefore web module 
[TemperatureConverterServiceClientEAR#AndroidBackendAuthentication.war] cannot be 
loaded at this context path on this virtual server. . Please see server.log for 
more details
Run Code Online (Sandbox Code Playgroud)

我去目录C:\glassfish3\glassfish\domains\domain1\eclipseApps并删除所有文件。我也去了 在此处输入图片说明

然后,我在服务器上单击。在default Web module选项中,我有以下条目

在此处输入图片说明

我如何从这里删除这些模块。每当我尝试部署Web服务时,都会收到此消息。我如何摆脱此消息?我还从“应用程序”选项中删除了已部署的模块,此后该default Web module选项变为空。但是如果我尝试部署任何Web服务,就会收到错误消息。请帮忙

谢谢。

glassfish-3

4
推荐指数
2
解决办法
9008
查看次数

获得意外令牌的错误:在第1行第135列附近开启

我是hibernate的新手,并试图在hibernate中运行查询,但我得到了异常

unexpected token: ON near line 1, column 135 [SELECT A.comp_id.appRefNo ....
Run Code Online (Sandbox Code Playgroud)

这是代码

StringBuffer query = new StringBuffer("SELECT A.comp_id.appRefNo, 
    A.comp_id.custId from ");

query.append(LosaCustContactZ.class.getName());

query.append(" A INNER JOIN " + LosaCust.class.getName() + " B 
    ON ( B.comp_id.appRefNo = A.comp_id.appRefNo AND " + 
    "B.comp_id.custId = A.comp_id.custId) INNER JOIN " + LosaApp.class.getName() + " C 
    ON " + "(B.comp_id.appRefNo = A.comp_id.appRefNo) ");

query.append("WHERE C.comp_id.appRefNo != ?" + " AND C.appDt >= ? AND 
    A.contactT = 'PHONE'" ); 

if (StringUtils.isNotEmpty(phoneNums)) {
    query.append(" AND A.contact …
Run Code Online (Sandbox Code Playgroud)

hibernate hql

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

如果用户单击浏览器后退按钮,如何在会话到期时将用户移动到超时页面

我正在使用过滤器处理JSF 2.0中的会话到期.这是代码

  @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {

    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpServletResponse httpServletResponse = (HttpServletResponse) response;

    HttpSession session = httpServletRequest.getSession(false);

    if (session == null) {

        //session timeout check.
        if (httpServletRequest.getRequestedSessionId() != null && !httpServletRequest.isRequestedSessionIdValid()) {

            System.out.println("Session has expired");
            session = httpServletRequest.getSession(true);
            session.setAttribute("logedin", "0");    // public user               
            httpServletResponse.sendRedirect(timeoutPage);

        } else {

            session = httpServletRequest.getSession(true);
            session.setAttribute("logedin", "0");
            filterChain.doFilter(httpServletRequest, httpServletResponse);
        }
    } 
} //end of doFilter()
Run Code Online (Sandbox Code Playgroud)

但问题是,当会话到期并且用户点击后退按钮时,他会获得所有样式的页面.无论如何,当会话到期时,如果用户单击浏览器后退按钮,则他会指向timeoutPage.

还有一点,我也在我的页面上使用Prime Faces组件,比如datatable.我正在使用分页.如果会话超时,并且我单击分页,则不会出现会话到期消息.似乎ajax请求不调用过滤器?如何连接我的ajax事件,或者你可以说数据表分页事件到会话到期?

谢谢

jsf-2

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

如何在Fragment中为微调器设置ArrayAdapter

我试图在片段中向spinner添加项目.但我对上下文有疑问.因为在片段中没有上下文.我在这里怎么样

public class DetailFrag extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View scrollView = inflater.inflate(R.layout.myscrollview , container, false);       
        LinearLayout linearLayout = (LinearLayout) scrollView.findViewById(R.id.mylayout1);

        for (int i=0; i<questionList.size(); i++) {

            View verticalLinearLayout = inflater.inflate(R.layout.mylistrow,  null);
            View horizontalLInearLaoyout = verticalLinearLayout.findViewById(R.id.questionRow);
            TextView tv = (TextView) horizontalLInearLaoyout.findViewById(R.id.question);
            Spinner spinner = (Spinner) horizontalLInearLaoyout.findViewById(R.id.spinner);

            //Problem: how to define this in fragment createFromResource(this,...)
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                    this, R.array.options_array, android.R.layout.simple_spinner_item);

            EditText editText = (EditText) verticalLinearLayout.findViewById(R.id.txtMultiLine);

            String question = questionList.get(i).question;

            tv.setId(i);
            tv.setText(i …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-fragmentactivity

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

得到错误,没有找到元素'jpa:repositories'的声明

我收到以下错误

Line 84 in XML document from class path resource [car-job-app-context.xml] is 
invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 84; 
columnNumber: 154; cvc-complex-type.2.4.c: The matching wildcard is strict, but
no declaration can be found for element 'jpa:repositories'.
Run Code Online (Sandbox Code Playgroud)

这是我的档案

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:repository="http://www.springframework.org/schema/data/repository"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.2.xsd
                        http://www.springframework.org/schema/jdbc
                        http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
                        http://www.springframework.org/schema/data/repository
                        http://www.springframework.org/schema/data/repository/spring-repository.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                        http://www.springframework.org/schema/data/jpa
                        http://www.springframework.org/schema/data/jpa/spring-jpa-2.0.xsd" >

.....

<context:annotation-config/>

<context:component-scan base-package="pk.training.basitMahmood.service.impl" />

<jpa:repositories base-package="pk.training.basitMahmood.repository" entity-manager-factory-ref="emf" transaction-manager-ref="transactionManager" />
Run Code Online (Sandbox Code Playgroud)

这是我的maven依赖项的快照

Maven Dependency JARS

我也看到了同样的链接,说移动tx declarationcontext但它不起作用. 与我的问题相同的帖子.我在组合之前和之后尝试过,但错误仍然存​​在. …

spring jpa-2.0

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