小编cub*_*buk的帖子

在AngularJS和Nodejs之间共享代码

什么是共享前端和后端使用之间的代码的最佳方式javascript,特别之间说nodejsangularjs

事情是,我们使用的是相同的enums,并constant valueserror codes在这两个后端和前端.现在我们只是将每个更改复制并粘贴到两个平台上,这不是一个好的解决方案.还有一些可以共享的服务.

我见过像这样的图书馆browserify; 但那不是我想要的.我在寻找类似的解决方案maven dependencyjava.在java,库可以轻松共享使用maven,而我找不到类似的方式来做到这一点javascript.有没有办法隔离这些服务并将它们作为依赖于独立nodejs使用npmangularjs使用bower?或者在前端和后端之间共享相同代码的方法是什么?

javascript node.js npm angularjs bower

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

如何避免jsf中的BusyConversationException

我在浏览jsf项目中的页面时遇到BusyConversationException.如果用户在ajax调用期间尝试导航到另一个页面,则通常会发生这种情况.当用户在单击另一个链接后立即单击链接而不等待加载页面时,也会发生这种情况.

例如,如果用户点击通过类似于下面的代码生成的多个链接,我们肯定会得到此异常.另一个例子是,假设用户在文本字段上输入查询,我们的应用程序进行ajax调用以搜索此查询.在该查询期间,如果用户单击某个按钮以导航到另一个页面,则也会发生BusyConversationException.

<h:commandLink value="#{theProfile.profileName}"
               title="#{theProfile.profileName}"
               action="#{profileBean.aProfileSelected}">
               <f:setPropertyActionListener target="#{currentProfileWebBean.theProfile}" value="#{theProfile}"/>
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

我能赶上在一个延伸ExceptionHandlerWrapper类中的ExceptionHandler类这种类型的异常,但我不能挽救我目前的状态,我可以为这种情况下做的最好的是,当这个例外发生时重定向到主页.

有没有解决方案来避免这种情况?提前感谢您的回答和评论.

jsf exception-handling cdi conversation-scope weld

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

如何改变select2标签的颜色?

我刚开始使用项目从选择框中显示多个标签,并且它非常好用,感谢库.

我只需要修改多值选择框中显示的标签的颜色或css.现在标签的颜色显示为灰色,我想根据标签的类型将其更改为其他颜色.或者至少有办法改变默认颜色?

还可以更改标签的css类吗?有一个选项,formatResultCssClass但是当我试图通过该属性添加css类没有任何改变时,我将不胜感激,如果有人可以展示如何做到这一点的例子?

编辑:解决问题的解决方法:向select2.defaults添加新属性以表示所选对象的类.

$.fn.select2.defaults = {
...
    selectedTagClass: "",
...
}

addSelectedChoice: function (data) {
        var choice=$(
            "<li class='select2-search-choice " + this.opts.selectedTagClass + "'>" +
            "    <div><a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'><i class='icon-remove icon-white'/></a></div>" +
            "</li>"),
        id = this.id(data),
        val = this.getVal(),
        formatted;
...
Run Code Online (Sandbox Code Playgroud)

并使用以下新属性初始化select2:

$(".#select2Input").select2({placeholder: "Please Select Country", 
                    selectedTagClass: 'label label-info', // label label-info are css classes that will be used for selected elements
                    formatNoMatches: function () { return "There isn't any country similar to entered …
Run Code Online (Sandbox Code Playgroud)

css twitter-bootstrap jquery-select2 jquery-select2-4

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

ViewPagerAndroid不使用React-Native在ScrollView下呈现

我可以使用ViewPagerAndroid,但当我把它放在ScrollView组件下时,没有任何东西被渲染.有没有人遇到过这个?

React-Native:版本0.22平台:Android

这按预期工作:

<ViewPagerAndroid style={{flex: 1}} initialPage={0}>
     <View><Text>View 1</Text></View>
     <View><Text>View 2</Text></View>
     <View><Text>View 3</Text></View>
</ViewPagerAndroid>;
Run Code Online (Sandbox Code Playgroud)

以下内容无效:

<ScrollView style={{flex: 1}}>
<ViewPagerAndroid style={{flex: 1}} initialPage={0}>
     <View><Text>View 1</Text></View>
     <View><Text>View 2</Text></View>
     <View><Text>View 3</Text></View>
</ViewPagerAndroid>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我在github上也创建了一个问题: #6469

android android-viewpager react-native

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

在 Java REST API 中注入到 ContainerRequestFilter

我想我正在处理 Glassfish 4 中的一个错误;但我不确定。基本上我试图将服务注入到 ContainerRequestFilter 中;但我在尝试时遇到了异常。我可以在进行休息调用的资源中进行注入,但不能对过滤器使用注入。glassfish jira 中有一个已归档的错误:https : //java.net/jira/browse/GLASSFISH-20597。我尝试了那里提到的解决方法,但没有解决我的问题。

这是我得到的例外:

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee&#40;requiredType=Authenticator,parent=SecurityInterceptor,qualifiers
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的代码,您知道我在这里缺少什么吗?

@Provider
@PreMatching
public class SecurityInterceptor implements ContainerRequestFilter {

@Inject
private Authenticator authenticator; // can't inject this service here, but I can inject this to RequestScoped Resources
private static final Logger LOG = Logger.getLogger(SecurityInterceptor.class.getName());

@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    if (!requestContext.getMethod().equals("OPTIONS")) {
        String path = OyumBuFunctions.normalizeString(requestContext.getUriInfo().getPath());
            String authToken = requestContext.getHeaderString(OyumbuRestHeaders.AUTH_TOKEN_HEADER);
            if (!authenticator.isAuthTokenValid(authToken)) {
                requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build()); …
Run Code Online (Sandbox Code Playgroud)

java rest glassfish jax-rs jersey

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

使用React-Native将content:// URI转换为Android的实际路径

我正在尝试上传图片cameraRoll.事情是cameraRoll组件返回content:// URI而不是实际的文件路径.要上传图像,我需要一个文件路径,有没有办法将content:// URI转换为文件URI?谢谢

android react-native react-native-camera

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

使用Webpack的缓存失效

我将hashID 附加到由生成的包中webpack。每当我得到一个新的版本时,我都会看到文件名被新的哈希值更改,并且index.html文件引用了这些文件。但是,部署我的应用程序后,使用Chrome的某些用户只有从应用程序注销后才能看到新文件。有人遇到过这个问题吗,知道解决任何问题的解决方案吗?

caching google-chrome nginx cache-invalidation webpack

5
推荐指数
0
解决办法
216
查看次数

如何将 Node 环境变量传递给 React Native JS 代码

我试图从 React Native 的 JS 代码访问节点环境变量,但不知何故,我传递的任何内容都没有被使用。

如果我尝试类似的事情:

NODE_ENV=test react-native run-android

我希望process.env.NODE_ENV等于,test但它会被覆盖productiondevelopment根据__DEV__捆绑请求的参数。

在 React Native 中将环境变量传递给 JS 代码的建议方法是什么?

谢谢

javascript environment-variables node.js react-native

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

如何用morphia注释复合键上的索引

我正在使用morphia github 1.2.2版.我知道如何在morphia实体上的一个字段上注释索引,但有没有办法在两个字段的组合上注释索引.例如,如果我想在字段a和b上有一个复合索引,那么下一个类的注释是什么.

@Entity
public class TestClass
{
    @Property("a")
    private int fieldA;
    @Property("b")
    private int fieldB;
    //how to annotate index of compound key fieldA and fieldB using morphia index annotation?
}
Run Code Online (Sandbox Code Playgroud)

提前致谢.

mongodb morphia mongodb-java

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

Jsf 2.0- <ui:include> xhtml总是包含,即使渲染是假的

我有一个主页xhtml,我根据条件包括3个孩子xhtml.我面临的问题是,无论情况如何,Book.xhtml总是被调用.我将渲染条件更改为false或移出到另一个条件,但始终调用该文件由于其调用其支持bean而导致不必要的开销.请给我一个解决方案

<ui:composition template="/xhtml/baseLayout.xhtml">
    <ui:define name="browserTitle">
        <h:outputText value="HOME PAGE" />
    </ui:define>
    <ui:define name="header">
        <ui:include src="/xhtml/header.xhtml" />
    </ui:define>
    <ui:define name="bodyContent">

        <h:panelGrid width="100%"
            rendered="#{pogcore:isRoleAuthorized(BUNDLE.SUPER)}"  >
            <ui:include src="/xhtml/SuperUser.xhtml"  />
        </h:panelGrid>
        <h:panelGrid width="100%"
            rendered="#{pogcore:isRoleAuthorized(BUNDLE.MAINTENANCE)}" >
            <ui:include src="/xhtml/Maintenance.xhtml" />
        </h:panelGrid>

        <h:panelGrid width="100%"
            rendered="#{pogcore:isRoleAuthorized(BUNDLE.PRINT)}">
            <ui:include src="/xhtml/Book.xhtml" />
        </h:panelGrid>

    </ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

xhtml jsf jstl jsf-2 uiinclude

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

平等问题在等于比较

我对以下语法有一个奇怪的问题:

以下代码块不会抛出空指针异常

Map<String, String> requestHeaderMap = FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap();

if(!"partial/ajax".equals(requestHeaderMap.get("faces-request")))    
{
    System.out.println("This works");
}
Run Code Online (Sandbox Code Playgroud)

但是这个抛出空指针异常:

FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap().get("faces-request").equals("partial/ajax")
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚这里有什么不对.除了可读性之外,我没有看到两个电话之间有任何区别.

java equals nullpointerexception

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