如何在Firefox中使用XUL创建底部停靠面板?(How to create a bottom-docked panel with XUL in Firefox?)
对于我的插件,我想创建一个底部停靠的“面板”,它将显示信息。 这样的例子就是Firefox自己的Web Console面板,可以在Web Developer Tools下切换。
我试图挖掘代码,但无法弄清楚这是如何实现的。 有人能给我一个如何用XUL创建这个的基本解释,或者指出我正确的方向?
For my addon, I would like to create a bottom-docked "panel" that will display information. An example of something like this would be Firefox's own Web Console panel that can be toggled under Web Developer Tools.
I tried to dig through the code, but couldn't figure out how this was implemented. Could someone give me a a basic explanation of how to create this with XUL, or point me in the right direction?
原文:https://stackoverflow.com/questions/25961877
最满意答案
您需要调用
ResultSet#next()
以将光标从当前位置向前移动一行。 由于您期望从查询中返回单个行,因此您可以在if
语句中调用它,如下所示:public Position extractData(ResultSet rs) throws SQLException, DataAccessException { Position p = new Position(); if(rs.next()) { p.setId(rs.getString("id")); p.setPositionName(rs.getString("position_name")); p.setDescription(rs.getString("description")); } return p; }
如果您期望处理多个结果并返回某种类型的集合,那么您可以
while(rs.next())
进行处理,并在循环的每次迭代中处理一行。另外,当你使用
JdbcTemplate
你可以考虑使用RowMapper
,它可能会稍微简化你的实现。You need to call
ResultSet#next()
to "move the cursor forward one row from its current position." As you are expecting a single row to be returned from your query, you can call this in anif
statement as shown below:public Position extractData(ResultSet rs) throws SQLException, DataAccessException { Position p = new Position(); if(rs.next()) { p.setId(rs.getString("id")); p.setPositionName(rs.getString("position_name")); p.setDescription(rs.getString("description")); } return p; }
If you were expecting to process multiple results and return a collection of some sort, you would do
while(rs.next())
and process a row on each iteration of the loop.Also, as you are using
JdbcTemplate
you could consider using aRowMapper
instead which may simplify your implementation slightly.
相关问答
更多-
@Tolegen Izbassar对于EE5,我很抱歉。 关于Singleton和EE5,有一些替代方案。 一个是供应商特定的扩展,例如JBoss 5.x有服务bean提供Singleton + JMX。 第二个解决方案是使用与EE5兼容的早期版本的Jboss Seam。 第三种方法是使用Servlet API中的ServerContext。 你在@PostConstuct中试图做的绝对不是好事。 SLSB中的非最终静力学是不可行的。 我建议看看Spring框架参考中的第29.3节,它描述了EJB-Spri ...
-
MERGE JDBCTemplate问题(MERGE JDBCTemplate issue)[2022-04-18]
正确的语法使用: MERGE INTO people AS t USING ( VALUES (5, 'Chuck', 'Norris'), (6, 'John', 'Smith'), (7, 'Abraham', 'Lincoln') -- maybe more rows ) AS s (id, name, surname) ON t.id = s.id WHEN ... -
Spring在JDBCTemplate中实现异常处理(Spring's implementation of Exception Handling in JDBCTemplate)[2023-09-02]
有些人不喜欢检查异常,因为他们强迫你做一些异常管理。 我想春天的人都是这种人。 就我个人而言,我更喜欢做他们打算做的事情: try { // execute some SQL } catch (SQLException ex) { if (ex is an expected condition) { // deal with it: for example with a "no data found" condition // this might mean ... -
JdbcTemplate.execute()抛出异常Spring Boot(JdbcTemplate.execute() throws exception Spring Boot)[2022-02-05]
我认为你没有得到jdbctemplate对象修复这个问题,看看你的依赖注入与专有名称。 I think you are not getting jdbctemplate object fix that issue, look on your dependency injection with proper names. -
我得到了一位同事的帮助,这就是我所做的: 我为ObjectMothers做了一个注释: package com.util.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType ...
-
jdbcTemplate更新中的Spring瞬态数据访问资源异常(Spring Transient Data Access Resource Exception in jdbcTemplate update)[2022-05-14]
你可以使用queryForList()方法,如下所示: results = jdbcTemplate.queryForList(sql,new Object[]{username},String.class); if(results.isEmpty(){ //no duplicate } else{ //duplicate } results是List。 You can use the queryForList() method of jdbcTemplate like th ... -
您需要调用ResultSet#next()以将光标从当前位置向前移动一行。 由于您期望从查询中返回单个行,因此您可以在if语句中调用它,如下所示: public Position extractData(ResultSet rs) throws SQLException, DataAccessException { Position p = new Position(); if(rs.next()) { p.setId(rs.g ...
-
你还在使用JDBC - 所以重新编写你的语句 String sql = "insert into table1 (columns1, columns2) values (?,?)"; 你会没事的或者 使用NamedParameterJdbcTemplate作为模板。 You're still using JDBC under the hood - so recode your statement to String sql = "insert into table1 (columns1, columns2 ...
-
这不是JdbcTemplate的错。 原因如下: 首先 ,您必须减少建立连接的开销。 这个开销可能高达500毫秒。 这很正常 。 其次 ,当您在MySQL客户端上运行查询时,是否在运行程序后立即运行它? 因为查询得到缓存......即使在磁盘I / O级别也是如此。 因此,如果您运行相同的查询两次,第二次它将由于缓存而运行得更快。 第三 ,你是否索引列name ? 第四 ,如果连接开销对您来说真的很重要,您可以考虑保留连接甚至连接池。 It's not JdbcTemplate's fault. Here' ...
-
我的JDBCTemplate代码对select操作有什么问题?(What is wrong with my JDBCTemplate code for select operation?)[2022-05-17]
你试图用RowMapper作为第二个参数(转换为Object[] )来调用queryForList(String sql, Object... args)方法,而后者又作为参数提供给JDBC的PreparedStatement.setObject这不是你的意思由于您的RowMapper实现不是Serializable ,因此无法正常工作。 queryForList方法都不接受RowMapper作为第二个参数,而是在使用query(String, RowMapper)方法之后得到结果。 You're t ...