小编Pet*_*zov的帖子

如何在JSF表中显示行号?

我有这个JSF表.我想添加行号.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <h:outputStylesheet library="css" name="table-style.css"  />
    </h:head>
    <h:body>

        <h1>JSF 2 dataTable example</h1>
        <h:form>
            <h:dataTable value="#{order.orderList}" var="o"
                styleClass="order-table"
                headerClass="order-table-header"
                rowClasses="order-table-odd-row,order-table-even-row"
            >
                        <h:column>

                    <f:facet name="header">No</f:facet>

                    <h:inputText value="#{order.orderList.rowIndex + 1}" size="10" rendered="false" />

                    <h:outputText value="#{order.orderList.rowIndex + 1}" rendered="#{not order.orderList.rowIndex + 1}" />

                </h:column>
                <h:column>

                    <f:facet name="header">Order No</f:facet>

                    <h:inputText value="#{o.orderNo}" size="10" rendered="#{o.editable}" />

                    <h:outputText value="#{o.orderNo}" rendered="#{not o.editable}" />

                </h:column>

                <h:column>

                    <f:facet name="header">Product Name</f:facet>

                    <h:inputText value="#{o.productName}" size="20" rendered="#{o.editable}" …
Run Code Online (Sandbox Code Playgroud)

java jsf jsf-2

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

没有正确计算到JSF页面的分页

我想实现本教程中的代码

我用14行数据填充了Oracle表,但是当我每次第二页为空时尝试在JSF页面之间导航时:

在此输入图像描述

在此输入图像描述

这是JSF页面的代码:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <ui:insert name="header">           
            <ui:include src="header.xhtml"/>         
        </ui:insert>
    </h:head>
    <h:body>

        <h1><img src="resources/css/images/icon.png" alt="NVIDIA.com" /> History Center</h1>
        <!-- layer for black background of the buttons -->
        <div id="toolbar" style="margin: 0 auto; width:1180px; height:30px; position:relative;  background-color:black">
            <!-- Include page Navigation -->
            <ui:insert name="Navigation">           
                <ui:include src="Navigation.xhtml"/>         
            </ui:insert>

        </div>  

        <div id="greenBand" class="ui-state-default ui-corner-allh" style="position:relative; top:35px; left:0px;"> 
            <h:graphicImage alt="Dashboard"  style="position:relative; top:-20px; left:9px;"  value="resources/images/logo_sessions.png" …
Run Code Online (Sandbox Code Playgroud)

java sql jsf jsf-2

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

双击树节点时如何触发事件

我有这个代码在远程Java类中创建新选项卡.

treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
        {
            @Override
            public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue, TreeItem<String> newValue)
            {
                System.out.println("Selected Text : " + newValue.getValue());
                // Create New Tab
                Tab tabdata = new Tab();
                Label tabALabel = new Label("Test");
                tabdata.setGraphic(tabALabel);

                DataStage.addNewTab(tabdata);
            }
        });
Run Code Online (Sandbox Code Playgroud)

你能告诉我当我双击树节点时如何修改代码以打开新选项卡.在我的代码中,单击一次时将打开选项卡.我需要什么事件处理程序?

javafx javafx-2 javafx-8

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

获取密钥组合代码

我想问你能否获得多个密钥的密钥代码组合.例如,我可以从此示例中获取密钥代码:

        public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.TAB) { 
        }
Run Code Online (Sandbox Code Playgroud)

但是我怎么能得到这个例子的关键代码:

textField.setText("");
                // Process only desired key types
                if (event.getCode().isLetterKey()
                        || event.getCode().isDigitKey()
                        || event.getCode().isFunctionKey()) {
                    String shortcut = event.getCode().getName();
                    if (event.isAltDown()) {
                        shortcut = "Alt + " + shortcut;
                    }
                    if (event.isControlDown()) {
                        shortcut = "Ctrl + " + shortcut;
                    }
                    if (event.isShiftDown()) {
                        shortcut = "Shift + " + shortcut;
                    }
                    textField.setText(shortcut);
                    shortcutKeyEvent = event;
                } else {
                    shortcutKeyEvent = null;
                }
Run Code Online (Sandbox Code Playgroud)

是否可以获得这些密钥的密钥代码组合Ctrl + Tab或 …

javafx javafx-8

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

仅使用2个CPU内核和Java

有没有办法将Java应用程序编码为仅使用CPU的2个CPU内核.例如,我想设置CPU利用率的限制.这在Java中可行吗?

java

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

将舞台导出为 PDF

有没有办法将 Stage 或其他一些组件(例如带有可视组件的 BorderPane)导出到 PDF 文件中?我想当我单击按钮时将组件导出为 PDF 文件?有例子吗?

javafx javafx-2 javafx-8

6
推荐指数
2
解决办法
9313
查看次数

图像 ID '[ami-fd9cecc7]' 不存在

我想远程使用此 Java 代码创建 EC2 实例:

public void testEC2ServiceInRegion() throws Exception
    {

        String launchInstance = launchInstance();
        System.out.println("Status " + launchInstance);
    }

    public String launchInstance()
    {
        BasicAWSCredentials bawsc = new BasicAWSCredentials(
            "AKIAIUY1KF4KZV3DAL21", "Onv+nq33tUkiLl1Ib2H9JtIB732QMEesh01Jl73L");

        AmazonEC2 ec2 = new AmazonEC2Client(bawsc);
        System.out.println("\n\nLAUNCH INSTANCE\n\n");

        try
        {
            // Construct a RunInstancesRequest.
            RunInstancesRequest request = new RunInstancesRequest();
            request.setImageId("ami-fd9cecc7"); // the AMI ID, ami-fd9cecc7 is Amazon Linux AMI 2015.03 (HVM)
            request.setInstanceType("t2.micro");    // instance type
            request.setKeyName("desktop");      // the keypair
//          request.setSubnetId("subnet-2dc0d459"); // the subnet
//          ArrayList list = new ArrayList(); …
Run Code Online (Sandbox Code Playgroud)

java amazon-ec2 amazon-web-services

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

Java代码中的Hardcode Hibernate值

我想用硬编码的Hibernate配置值创建JUnit测试:

public class UserProvisionTest
{
        public static SessionFactory buildTestSessionFactory()
    {
        Configuration configuration = new Configuration();

        configuration.setProperty("hibernate.show_sql", "true");
        configuration.setProperty("hibernate.connection.url", "jdbc:sqlite:/Users/Desktop/testDB.sqlite");
        configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLiteDialect");
        configuration.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
        configuration.setProperty("hibernate.connection.release_mode", "auto");
        configuration.setProperty("hibernate.connection.autoReconnect", "true");
        configuration.setProperty("hibernate.hbm2ddl.auto", "update");
        configuration.setProperty("hibernate.current_session_context_class", "thread");
        configuration.addAnnotatedClass(SystemUserModel.class);

        configuration.configure();
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
        System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");

        return configuration.buildSessionFactory();
    }

    @Test
    public void createUsersTest() throws Exception
    {
        System.out.println("Creating default users");

        Session session = buildTestSessionFactory().getCurrentSession();
        Transaction tr = session.beginTransaction();

        // some query
        session.flush();
        tr.commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我收到此错误:

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:271)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
    at …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

引起:java.lang.ClassNotFoundException:org.springframework.boot.actuate.health.StatusAggregator

我有这个渐变配置:

梯度

plugins {
    id 'org.springframework.boot' version '2.4.10'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.test'
version = '0.0.1'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "2020.0.3")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
    implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer'
    implementation 'com.netflix.eureka:eureka-core'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'javax.validation:validation-api'
    implementation 'org.hibernate.validator:hibernate-validator'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    // Lombook
    compileOnly 'org.projectlombok:lombok:1.18.20'
    annotationProcessor 'org.projectlombok:lombok:1.18.20'
    testCompileOnly 'org.projectlombok:lombok:1.18.20'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
    // Mapstruct
    implementation 'org.mapstruct:mapstruct:1.4.2.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
    runtimeOnly 'org.postgresql:postgresql'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" …
Run Code Online (Sandbox Code Playgroud)

spring spring-boot netflix-eureka

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

实现 React Material 表的分页

我有这个 Spring Boot 端点用于列出数据库中的项目:

import React, { useEffect, useState } from "react";

import clsx from "clsx";
import {
  createStyles,
  lighten,
  makeStyles,
  Theme,
} from "@material-ui/core/styles";
import CircularProgress from "@material-ui/core/CircularProgress";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableContainer from "@material-ui/core/TableContainer";
import TableHead from "@material-ui/core/TableHead";
import TablePagination from "@material-ui/core/TablePagination";
import TableRow from "@material-ui/core/TableRow";
import TableSortLabel from "@material-ui/core/TableSortLabel";
import Toolbar from "@material-ui/core/Toolbar";
import Typography from "@material-ui/core/Typography";
import Paper from "@material-ui/core/Paper";
import Checkbox from "@material-ui/core/Checkbox";
import IconButton from …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs spring-boot material-ui react-typescript

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