问:
Using pandoc and pandoc-citeproc with Jupyter notebooks
I am developing an infrastructure where developers can document their verification tests using Jupyter notebooks. One part of the infrastructure will be a python script that can convert their .ipynb files to .html files to provide public-facing documentation of their tests.

Using the nbconvert module does most of what I want, but I would like to allow citations and references in the final HTML file. I can use pypandoc to generate HTML text that converts the citations to proper inlined syntax and adds a References section:

```<code>from urllib import urlopen
import nbformat
import pypandoc
from nbconvert import MarkdownExporter

response = urlopen('SimpleExample.ipynb').read().decode()
notebook = nbformat.reads(response, as_version=4)
exporter = MarkdownExporter()
(body, resources) = exporter.from_notebook_node(notebook)

filters = ['pandoc-citeproc']
extra_args = ['--bibliography="ref.bib"',
              '--reference-links',
              '--csl=MWR.csl']
new_body = pypandoc.convert_text(body,
                                 'html',
                                 'md',
                                 filters=filters,
                                 extra_args=extra_args)
</code>```

The problem is that this generated HTML loses all of the considerable formatting and other capabilities provided by nbconvert.HTMLExporter.

My question is, is there a straightforward way to merge the results of nbconvert.HTMLExporter and pypandoc.convert_text() such that I get mostly the former, with inline citations and a Reference section added from the latter?

答:
I don't know that this necessarily counts as "straightforward" but I was able to come up with a solution. It involves writing a class that inherits from nbconvert.preprocessors.Preprocessor and implements the preprocess(self, nb, resources) method. Here is what preprocess() does:

Loop over every cell in the notebook and store a set of citation keys (these are of the form [@bibtex_key]

Create a short body of text consisting of only these citation keys, each separated by '\n\n'

Use the pandoc conversion above to generate HTML text from this short body of text. If num_cite is the number of citations, the first num_cite lines of the generated text will be the inline versions of the citations (e.g. '(Author, Year)'); the remaining lines will be the content of the references section.

Go back through each cell and substitute the inline text of each citation for its key.

Add a cell to the notebook with ## References

Add a cell to the notebook with the content of the references section

Now, when an HTMLExporter, using this Preprocessor, converts a notebook, the results will have inline citations, a reference section, and all of the formatting you expect from the HTMLExporter.

Body:
I am developing an infrastructure where developers can document their verification tests using Jupyter notebooks. One part of the infrastructure will be a python script that can convert their .ipynb files to .html files to provide public-facing documentation of their tests.

Using the nbconvert module does most of what I want, but I would like to allow citations and references in the final HTML file. I can use pypandoc to generate HTML text that converts the citations to proper inlined syntax and adds a References section:

from urllib import urlopen
import nbformat
import pypandoc
from nbconvert import MarkdownExporter

response = urlopen('SimpleExample.ipynb').read().decode()
notebook = nbformat.reads(response, as_version=4)
exporter = MarkdownExporter()
(body, resources) = exporter.from_notebook_node(notebook)

filters = ['pandoc-citeproc']
extra_args = ['--bibliography="ref.bib"',
              '--reference-links',
              '--csl=MWR.csl']
new_body = pypandoc.convert_text(body,
                                 'html',
                                 'md',
                                 filters=filters,
                                 extra_args=extra_args)

The problem is that this generated HTML loses all of the considerable formatting and other capabilities provided by nbconvert.HTMLExporter.

My question is, is there a straightforward way to merge the results of nbconvert.HTMLExporter and pypandoc.convert_text() such that I get mostly the former, with inline citations and a Reference section added from the latter?


来源: stackexchange

问:
Getting the first class from multiple classes with the same name with BeautifulSoup
I am trying to extract information from this page which has it's HTML as below.

I am trying to extract the text in the first class="currentServers" (example: I get 745,807 from this line 745,807

The problem is that in the row there are two spans with class name class="currentServers". I want to get the value in the first column of the row.

HTML:

```<code><tr class="player_count_row" style="">
                            <td align="right">
                                <span class="currentServers">745,807</span>
                            </td>
                            <td align="right">
                                <span class="currentServers">836,540</span>
                            </td>
                            <td width="20"> </td>
                            <td>
                                <a class="gameLink" onmouseover="GameHover( this, event, 'global_hover', {"type":"app","id":570,"v6":1} );" onmouseout="HideGameHover( this, event, 'global_hover' )" href="http://store.steampowered.com/app/570/">Dota 2</a>
                            </td>
                        </tr>
</code>```

I feel that I am close but I can't figure it out.

This is what I tried:

```<code>def GetTopGamesByPlayers():
    response = requests.get(url)
    html = response.content

    soup = BeautifulSoup(html)

    r = []

    final_link = soup.p.a
    final_link.decompose()

    links = soup.findAll("a", { "class" : "gameLink" })
    currentPlayers = soup.findAll("span", {"class" : "currentServers"})

    players = ""
    i = 0

    for player in currentPlayers :
        for link in links:
            players = currentPlayers[0].text
            try:
                appid = link.get('onmouseover')
                appid = findAppIdFromStats(appid,'"id":' , ',"public":1')
                linkg = link.get('href')
            except AttributeError:
                r.append(["N/A","N/A","N/A"])
            r.append([appid,linkg,players])

    c = ["N/A","N/A", "N/A"]
    while c in r:
        r.remove(c)
    return r

def findAppIdFromStats( s, first, last ):
      try:
        start = s.index( first ) + len( first )
        end = s.index( last, start )
        return s[start:end]
      except ValueError:
            return "first: " + first + "last: " + last
</code>```

The below is the output :

```<code>[u'346110', u'http://store.steampowered.com/app/346110/', u'745,807']
[u'230410', u'http://store.steampowered.com/app/230410/', u'745,807']
[u'252950', u'http://store.steampowered.com/app/252950/', u'745,807']
[u'482730', u'http://store.steampowered.com/app/482730/', u'745,807']
[u'252490', u'http://store.steampowered.com/app/252490/', u'745,807']
[u'4000', u'http://store.steampowered.com/app/4000/', u'745,807']
[u'444090', u'http://store.steampowered.com/app/444090/', u'745,807']
[u'359550', u'http://store.steampowered.com/app/359550/', u'745,807']
[u'588430', u'http://store.steampowered.com/app/588430/', u'745,807']
[u'374320', u'http://store.steampowered.com/app/374320/', u'745,807']
[u'8930', u'http://store.steampowered.com/app/8930/', u'745,807']
[u'107410', u'http://store.steampowered.com/app/107410/', u'745,807']
[u'238960', u'http://store.steampowered.com/app/238960/', u'745,807']
[u'304930', u'http://store.steampowered.com/app/304930/', u'745,807']
[u'10', u'http://store.steampowered.com/app/10/', u'745,807']
[u'72850', u'http://store.steampowered.com/app/72850/', u'745,807']
[u'289070', u'http://store.steampowered.com/app/289070/', u'745,807']
[u'105600', u'http://store.steampowered.com/app/105600/', u'745,807']
[u'377160', u'http://store.steampowered.com/app/377160/', u'745,807']
[u'236390', u'http://store.steampowered.com/app/236390/', u'745,807']
[u'292030', u'http://store.steampowered.com/app/292030/', u'745,807']
[u'227300', u'http://store.steampowered.com/app/227300/', u'745,807']
[u'386360', u'http://store.steampowered.com/app/386360/', u'745,807']
[u'236850', u'http://store.steampowered.com/app/236850/', u'745,807']
[u'364360', u'http://store.steampowered.com/app/364360/', u'745,807']
[u'381210', u'http://store.steampowered.com/app/381210/', u'745,807']
[u'363970', u'http://store.steampowered.com/app/363970/', u'745,807']
[u'453480', u'http://store.steampowered.com/app/453480/', u'745,807'

... ... ...
</code>```

I want to extract the value that has the red ellipse around it:

(appid, Current Players, Game Name) - I can succesfully get the appid and game name for each game but not the Current Players in sequence

答:
Is there any reason that you are using two loops?

If not you can try with one loop and when looping the link, find the previous tr and then the first td which contains the player number that you want.

Example:

```<code>for link in links:
        players = currentPlayers[0].text
        try:
            appid = link.get('onmouseover')
            appid = findAppIdFromStats(appid,'"id":' , ',"public":1')
            linkg = link.get('href')
        except AttributeError:
            r.append(["N/A","N/A","N/A"])
        r.append([appid, linkg, link.find_previous("tr", class_="player_count_row").find("td").get_text(strip=True)])
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to extract information from this page which has it's HTML as below.

I am trying to extract the text in the first class="currentServers" (example: I get 745,807 from this line 745,807

The problem is that in the row there are two spans with class name class="currentServers". I want to get the value in the first column of the row.

HTML:

                                745,807

                                836,540

                                Dota 2

I feel that I am close but I can't figure it out.

This is what I tried:

def GetTopGamesByPlayers():
    response = requests.get(url)
    html = response.content

    soup = BeautifulSoup(html)

    r = []

    final_link = soup.p.a
    final_link.decompose()

    links = soup.findAll("a", { "class" : "gameLink" })
    currentPlayers = soup.findAll("span", {"class" : "currentServers"})

    players = ""
    i = 0

    for player in currentPlayers :
        for link in links:
            players = currentPlayers[0].text
            try:
                appid = link.get('onmouseover')
                appid = findAppIdFromStats(appid,'"id":' , ',"public":1')
                linkg = link.get('href')
            except AttributeError:
                r.append(["N/A","N/A","N/A"])
            r.append([appid,linkg,players])

    c = ["N/A","N/A", "N/A"]
    while c in r:
        r.remove(c)
    return r

def findAppIdFromStats( s, first, last ):
      try:
        start = s.index( first ) + len( first )
        end = s.index( last, start )
        return s[start:end]
      except ValueError:
            return "first: " + first + "last: " + last

The below is the output :

[u'346110', u'http://store.steampowered.com/app/346110/', u'745,807']
[u'230410', u'http://store.steampowered.com/app/230410/', u'745,807']
[u'252950', u'http://store.steampowered.com/app/252950/', u'745,807']
[u'482730', u'http://store.steampowered.com/app/482730/', u'745,807']
[u'252490', u'http://store.steampowered.com/app/252490/', u'745,807']
[u'4000', u'http://store.steampowered.com/app/4000/', u'745,807']
[u'444090', u'http://store.steampowered.com/app/444090/', u'745,807']
[u'359550', u'http://store.steampowered.com/app/359550/', u'745,807']
[u'588430', u'http://store.steampowered.com/app/588430/', u'745,807']
[u'374320', u'http://store.steampowered.com/app/374320/', u'745,807']
[u'8930', u'http://store.steampowered.com/app/8930/', u'745,807']
[u'107410', u'http://store.steampowered.com/app/107410/', u'745,807']
[u'238960', u'http://store.steampowered.com/app/238960/', u'745,807']
[u'304930', u'http://store.steampowered.com/app/304930/', u'745,807']
[u'10', u'http://store.steampowered.com/app/10/', u'745,807']
[u'72850', u'http://store.steampowered.com/app/72850/', u'745,807']
[u'289070', u'http://store.steampowered.com/app/289070/', u'745,807']
[u'105600', u'http://store.steampowered.com/app/105600/', u'745,807']
[u'377160', u'http://store.steampowered.com/app/377160/', u'745,807']
[u'236390', u'http://store.steampowered.com/app/236390/', u'745,807']
[u'292030', u'http://store.steampowered.com/app/292030/', u'745,807']
[u'227300', u'http://store.steampowered.com/app/227300/', u'745,807']
[u'386360', u'http://store.steampowered.com/app/386360/', u'745,807']
[u'236850', u'http://store.steampowered.com/app/236850/', u'745,807']
[u'364360', u'http://store.steampowered.com/app/364360/', u'745,807']
[u'381210', u'http://store.steampowered.com/app/381210/', u'745,807']
[u'363970', u'http://store.steampowered.com/app/363970/', u'745,807']
[u'453480', u'http://store.steampowered.com/app/453480/', u'745,807'

... ... ...

I want to extract the value that has the red ellipse around it:

(appid, Current Players, Game Name) - I can succesfully get the appid and game name for each game but not the Current Players in sequence

Body:
Is there any reason that you are using two loops?

If not you can try with one loop and when looping the link, find the previous tr and then the first td which contains the player number that you want.

Example:

for link in links:
        players = currentPlayers[0].text
        try:
            appid = link.get('onmouseover')
            appid = findAppIdFromStats(appid,'"id":' , ',"public":1')
            linkg = link.get('href')
        except AttributeError:
            r.append(["N/A","N/A","N/A"])
        r.append([appid, linkg, link.find_previous("tr", class_="player_count_row").find("td").get_text(strip=True)])


问:
is there any way to generate sql file using CodeIgniter source code
Recently my database got deleted due to some issues.I am using codeigniter for my project is there any way I can get the structure of my database from codeigniter source code.any help will be appreciated</p>

答:
Sorry to say but no. At least not entirely and it won't be easy. But you can extract some information that might help.

You can examine all the model files and learn what table names are used. You might also find the names of some fields. That won't tell you directly everything you need to know about the fields. But you might be able to figure out the data types.

You can also examine how the data returned from models is used in controllers and views. That might help you get a handle on data types. That might also be helpful in cases where the query is a Select * which provides no info on how many fields exist or what the names are.

Unless your application was very simple you have a long road ahead.

Let this be a lesson - Backup your projects including the database!


问:
How to loop through all Symbols and check the current bar and the previous one's High?
The problem is that when the i in the for loop reaches 15, I get an Array out of range error.

What I want to achieve is on every tick to check every Symbol in the MarketWatch and in each Symbol to check the current bar ( PERIOD_M5 ) and the previous one if there is a gap.

```<code>void OnTick()
{
 int size = ArraySize( Symbols );

 for( int i = 0; i < size; i++ )
 {
  int  current_bar_index     = iHighest( Symbols[i], PERIOD_M5, MODE_HIGH, 1, 0 );
  int previous_bar_index     = iHighest( Symbols[i], PERIOD_M5, MODE_HIGH, 1, 1 );
  int  current_bar_index_low = iLowest(  Symbols[i], PERIOD_M5, MODE_LOW,  1, 0 );
  int previous_bar_index_low = iLowest(  Symbols[i], PERIOD_M5, MODE_LOW,  1, 1 );

  double  current_high = High[ current_bar_index];
  double previous_high = High[previous_bar_index];
  double  current_low  = Low[  current_bar_index_low];
  double previous_low  = Low[ previous_bar_index_low];

  if (  current_low  > ( previous_high + 0.00002 )
     || current_high < ( previous_low  - 0.00002 )
        )
  {
     Print( "There is a gap" );
  }
 }
}
</code>```

Symbols[] is the array containing all the symbols. I loop through it and pass the current Symbol and get the index for the current bar and the previous one and then simply check if there is a gap.

The first problem is that passing every Symbol doesn't work. It gets only one and that's it. How can I achieve that and also, why I get an Array out of range error?

答:
about the error - when you receive it, it also can see the address of the code that generates it: number of line and symbol number in that line

about Symbol - as you may know, in MQL5 you can select all symbols from the market watch, in MQL4 such option is not available, as far as I remember, so I suspect your array of symbol names is empty or sth like that.

Could you show how you initialized that array? A correct way is the following one:

```<code>string Symbol[]={"EURUSD","AUDUSD","GBPUSD"};
</code>```

also your code doesn't make any sense - when you select iHighest(*,*,*,i,j) - that means that EA-code checks i-elements, starting from j-th element ( 1, 0 ) means a current bar only, ( 1, 1 ) means to select just 1 bar, starting from bar 1, so still only 1 Bar is used.

For that it is much easier to have

```<code>double  cur_high = iHigh( Symbol[i], 5, 0 ),
       prev_high = iHigh( Symbol[i], 5, 1 );
</code>```

Body:
The problem is that when the i in the for loop reaches 15, I get an Array out of range error.

What I want to achieve is on every tick to check every Symbol in the MarketWatch and in each Symbol to check the current bar ( PERIOD_M5 ) and the previous one if there is a gap.

void OnTick()
{
 int size = ArraySize( Symbols );

 for( int i = 0; i < size; i++ )
 {
  int  current_bar_index     = iHighest( Symbols[i], PERIOD_M5, MODE_HIGH, 1, 0 );
  int previous_bar_index     = iHighest( Symbols[i], PERIOD_M5, MODE_HIGH, 1, 1 );
  int  current_bar_index_low = iLowest(  Symbols[i], PERIOD_M5, MODE_LOW,  1, 0 );
  int previous_bar_index_low = iLowest(  Symbols[i], PERIOD_M5, MODE_LOW,  1, 1 );

  double  current_high = High[ current_bar_index];
  double previous_high = High[previous_bar_index];
  double  current_low  = Low[  current_bar_index_low];
  double previous_low  = Low[ previous_bar_index_low];

  if (  current_low  > ( previous_high + 0.00002 )
     || current_high < ( previous_low  - 0.00002 )
        )
  {
     Print( "There is a gap" );
  }
 }
}

Symbols[] is the array containing all the symbols. I loop through it and pass the current Symbol and get the index for the current bar and the previous one and then simply check if there is a gap.

The first problem is that passing every Symbol doesn't work. It gets only one and that's it. How can I achieve that and also, why I get an Array out of range error?

Body:
about the error - when you receive it, it also can see the address of the code that generates it: number of line and symbol number in that line

about Symbol - as you may know, in MQL5 you can select all symbols from the market watch, in MQL4 such option is not available, as far as I remember, so I suspect your array of symbol names is empty or sth like that.

Could you show how you initialized that array? A correct way is the following one:

string Symbol[]={"EURUSD","AUDUSD","GBPUSD"};

also your code doesn't make any sense - when you select iHighest(*,*,*,i,j) - that means that EA-code checks i-elements, starting from j-th element ( 1, 0 ) means a current bar only, ( 1, 1 ) means to select just 1 bar, starting from bar 1, so still only 1 Bar is used.

For that it is much easier to have

double  cur_high = iHigh( Symbol[i], 5, 0 ),
       prev_high = iHigh( Symbol[i], 5, 1 );


问:
Distribute and update an app to specifics users
I am looking for a solution to give the permission to specifics users to download and update my app in the PlayStore.

For example, adding the gmail account of the user in the Publisher Console to give the permission.

Is it possible ? How ?
Other solutions ? Maybe an other store ?

答: Set up closed alpha or beta test. With closed beta testing, you can create a list of beta testers by email address. You can create up to 50 lists per track with up to 2,000 users in each. Look here for more.</p>


问:
Creating a download link in a new page once a form is submited html
I have an HTML form that saves the information entered and puts it in an Excel file on the server. I want to make this file available for download once the form is submitted.

My current download button is

```<code><a href="data.xlsx">Download data</a>
</code>```

My form links to a Perl script that processes the data. However once the form is processed it goes to a new page. I would like the new page to either display an error message or a link to download the file. I am unsure how to link to a new page because my form is already linked to the perl script.

I'm not very familiar with HTML or JavaScript, so if anyone has a simple idea for me that would be appreciated.

答:
You can try jQuery and append your link like this:</p>

```<code>$('body').append('<a href\'data.xls\'>Download Link</a>');
</code>```

Body:
I have an HTML form that saves the information entered and puts it in an Excel file on the server. I want to make this file available for download once the form is submitted.

My current download button is

Download data

My form links to a Perl script that processes the data. However once the form is processed it goes to a new page. I would like the new page to either display an error message or a link to download the file. I am unsure how to link to a new page because my form is already linked to the perl script.

I'm not very familiar with HTML or JavaScript, so if anyone has a simple idea for me that would be appreciated.

Body:
You can try jQuery and append your link like this:

$('body').append('<a href\'data.xls\'>Download Link</a>');


问:
How to use Enum in Camel Route?
I have the following route:

```<code>.choise()
   .when()
      .simple("${body.messageType} == 105")
          .to(...)
   .when()
      .simple("${body.messageType} == 106")
          .to(...)
</code>```

I want to use this enum to compare.

```<code>  package myPackage;

  public enum Code {
     CODE_A("105"),
     CODE_B("106")

     private String value;

    Code(String value) {
        this.value = value;
    }

    public String value() {
        return value;
    }
}
</code>```

I tried to do something like this, but it doesn't works..

```<code>.simple("${body.messageType} == ${type:myPackage.Code.CODE_A.value()}")
</code>```

Any idea to solve this problem?

答:
You can solve it using Groovy expressions. Add camel-groovy to pom/gradle.

Use the following expression:

```<code>.when().groovy("body.messageType == myPackage.CODE_A.value()")
</code>```

Title: How to use Enum in Camel Route?

Body:
I have the following route:

.choise()
   .when()
      .simple("${body.messageType} == 105")
          .to(...)
   .when()
      .simple("${body.messageType} == 106")
          .to(...)

I want to use this enum to compare.

  package myPackage;

  public enum Code {
     CODE_A("105"),
     CODE_B("106")

     private String value;

    Code(String value) {
        this.value = value;
    }

    public String value() {
        return value;
    }
}

I tried to do something like this, but it doesn't works..

.simple("${body.messageType} == ${type:myPackage.Code.CODE_A.value()}")

Any idea to solve this problem?

Body:
You can solve it using Groovy expressions. Add camel-groovy to pom/gradle.

Use the following expression:

.when().groovy("body.messageType == myPackage.CODE_A.value()")


问:
vTiger Custom Field Validation beforesave
I have created a custom module on vTiger 6.5.

I have made an event handler for the module but I am wondering how I could perform some sort of validation on this field. So fat I have done this but I am unable to get it work, I have tested the handler just echoing a sting and it works fine.

Please see my code below. Thanks!

```<code>    <?php
/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *************************************************************************************/
# getModuleName : Returns the module name of the entity.
# getId : Returns id of the entity, this will return null if the id has not been saved yet.
# getData : Returns the fields of the entity as an array where the field name is the key and the fields value is the value.
# isNew : Returns true if new record is being created, false otherwise.
# 'vtiger.entity.beforesave.modifiable' : Setting values : $data->set('simple_field', 'value');

class isaHandler extends VTEventHandler {
    function handleEvent($eventName, $entityData) {
        global $adb;
        $moduleName = $entityData->getModuleName();
        if($moduleName=='isa'){
            if($eventName == 'vtiger.entity.beforesave.modifiable') {}
            if($eventName == 'vtiger.entity.beforesave') {
                if('currentamount' > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }

            }
            if($eventName == 'vtiger.entity.beforesave.final') {}
            if($eventName == 'vtiger.entity.aftersave') {
            }
        }
    }

}
?>
</code>```

答:
After doing some searching around and looking at other peoples event handlers I managed to solve this by changing:

```<code>if($eventName == 'vtiger.entity.beforesave') {
                if('currentamount' > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }
</code>```

to

```<code>if($eventName == 'vtiger.entity.beforesave') {
                $price = $entityData->get('currentamount');
                if($price > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }
</code>```

Now I want to see if I can display the message and then give a link to go back to the entity module with all the fields still full.

Body:
I have created a custom module on vTiger 6.5.

I have made an event handler for the module but I am wondering how I could perform some sort of validation on this field. So fat I have done this but I am unable to get it work, I have tested the handler just echoing a sting and it works fine.

Please see my code below. Thanks!

    <?php
/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *************************************************************************************/
# getModuleName : Returns the module name of the entity.
# getId : Returns id of the entity, this will return null if the id has not been saved yet.
# getData : Returns the fields of the entity as an array where the field name is the key and the fields value is the value.
# isNew : Returns true if new record is being created, false otherwise.
# 'vtiger.entity.beforesave.modifiable' : Setting values : $data->set('simple_field', 'value');

class isaHandler extends VTEventHandler {
    function handleEvent($eventName, $entityData) {
        global $adb;
        $moduleName = $entityData->getModuleName();
        if($moduleName=='isa'){
            if($eventName == 'vtiger.entity.beforesave.modifiable') {}
            if($eventName == 'vtiger.entity.beforesave') {
                if('currentamount' > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }

            }
            if($eventName == 'vtiger.entity.beforesave.final') {}
            if($eventName == 'vtiger.entity.aftersave') {
            }
        }
    }

}
?>

Body:
After doing some searching around and looking at other peoples event handlers I managed to solve this by changing:

if($eventName == 'vtiger.entity.beforesave') {
                if('currentamount' > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }

to

if($eventName == 'vtiger.entity.beforesave') {
                $price = $entityData->get('currentamount');
                if($price > 20000){
                    echo "Please go back and enter less than 20000";
                exit;
                }

Now I want to see if I can display the message and then give a link to go back to the entity module with all the fields still full.


问:
DOS batch: get last folder from relative path
I have the following values in a DOS batch file (for example...):

```<code>..\Apple\Jones
..\Banana\Smith
..\Pear\Wilson
</code>```

I need to extract the last name values ("Jones", "Smith", "Wilson") from each value.  What one technique can I use that will always give me these substring values?

答:
According to this topic : What is the best way to do a substring in a batch file?

I suggest you to use

```<code>%~n0
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I have the following values in a DOS batch file (for example...):

..\Apple\Jones
..\Banana\Smith
..\Pear\Wilson

I need to extract the last name values ("Jones", "Smith", "Wilson") from each value.  What one technique can I use that will always give me these substring values?

Body:
According to this topic : What is the best way to do a substring in a batch file?

I suggest you to use

%~n0


问:
SQL query is very slow
I have a query that is updating views and likes for posts for the last 24 hours, but it is very slow. For around 3000 posts it takes more than 15 seconds to complete, which is a big problem since other queries can't be executed during that period.

```<code>$update_query = mysqli_query($database, "UPDATE post SET
                likes_last_day = (SELECT COUNT(post_like_id) FROM post_like WHERE post.post_id = post_like.post_id AND post_like.date > ('$current_date' - INTERVAL 1 DAY)),
                views_last_day = (SELECT COUNT(post_view_id) FROM post_view WHERE post.post_id = post_view.post_id AND post_view.date > ('$current_date' - INTERVAL 1 DAY))");
</code>```

Is there a way to optimize this query to execute faster?

答:
To minimize the amount of time that locks are held on the post table, we can pre-aggregate the results into a temporary table, and then perform the update from that.

As an example:

```<code>DROP TEMPORARY TABLE IF EXISTS `__post_last_day_counts__`
;
CREATE TEMPORARY TABLE `__post_last_day_counts__`
( post_id        BIGINT NOT NULL COMMENT 'pk'
, likes_last_day BIGINT NOT NULL
, views_last_day BIGINT NOT NULL
, PRIMARY KEY (post_id)
) ENGINE=InnoDB
;
INSERT INTO `__post_last_day_counts__`
( post_id
, likes_last_day
, views_last_day
)
SELECT p.post_id
     , IFNULL(lc.likes_last_day,0) AS likes_last_day
     , IFNULL(vc.views_last_day,0) AS views_last_day
  FROM post p
  LEFT
  JOIN ( SELECT pl.post_id
              , COUNT(pl.post_id) AS likes_last_day
           FROM post_like pl
          WHERE pl.date > ('$current_date' - INTERVAL 1 DAY)
       ) lc
    ON lc.post_id = p.post_id
  LEFT
  JOIN ( SELECT pv.post_id
              , COUNT(pv.post_id) AS views_last_day
           FROM post_view pv
          WHERE pv.date > ('$current_date' - INTERVAL 1 DAY)
       ) vc
    ON vc.post_id = p.post_id
;
</code>```

With the counts in the temporary table, we can update post table...

```<code>UPDATE post t
  JOIN `__post_last_day_counts__` s
    ON s.post_id = t.id
   SET t.likes_last_day = s.likes_last_day
     , t.views_last_day = s.views_last_day
;
</code>```

And cleanup...

```<code>DROP TEMPORARY TABLE IF EXISTS `__post_last_day_counts__`
;
</code>```

Overall this is probably slower, but it may minimize the amount of time that the UPDATE statement holds locks.

NOTE: datatype of the post_id column in the temporary table should match the datatype of post_id in the post table.  I just took a guess.

We are assuming that post_id is the primary key (or unique key) of post table.

Make sure suitable indexes are available:

```<code>... on post_view (post_id, date)
... on post_like (post_id, date)
</code>```

Use EXPLAIN to see execution plan, which operations are being performed and which indexes are being used. (We want to see "Using index for group" in the Extra column.)

Title: SQL query is very slow

Body:
I have a query that is updating views and likes for posts for the last 24 hours, but it is very slow. For around 3000 posts it takes more than 15 seconds to complete, which is a big problem since other queries can't be executed during that period.

$update_query = mysqli_query($database, "UPDATE post SET
                likes_last_day = (SELECT COUNT(post_like_id) FROM post_like WHERE post.post_id = post_like.post_id AND post_like.date > ('$current_date' - INTERVAL 1 DAY)),
                views_last_day = (SELECT COUNT(post_view_id) FROM post_view WHERE post.post_id = post_view.post_id AND post_view.date > ('$current_date' - INTERVAL 1 DAY))");

Is there a way to optimize this query to execute faster?

Body:
To minimize the amount of time that locks are held on the post table, we can pre-aggregate the results into a temporary table, and then perform the update from that.

As an example:

DROP TEMPORARY TABLE IF EXISTS `__post_last_day_counts__`
;
CREATE TEMPORARY TABLE `__post_last_day_counts__`
( post_id        BIGINT NOT NULL COMMENT 'pk'
, likes_last_day BIGINT NOT NULL
, views_last_day BIGINT NOT NULL
, PRIMARY KEY (post_id)
) ENGINE=InnoDB
;
INSERT INTO `__post_last_day_counts__`
( post_id
, likes_last_day
, views_last_day
)
SELECT p.post_id
     , IFNULL(lc.likes_last_day,0) AS likes_last_day
     , IFNULL(vc.views_last_day,0) AS views_last_day
  FROM post p
  LEFT
  JOIN ( SELECT pl.post_id
              , COUNT(pl.post_id) AS likes_last_day
           FROM post_like pl
          WHERE pl.date > ('$current_date' - INTERVAL 1 DAY)
       ) lc
    ON lc.post_id = p.post_id
  LEFT
  JOIN ( SELECT pv.post_id
              , COUNT(pv.post_id) AS views_last_day
           FROM post_view pv
          WHERE pv.date > ('$current_date' - INTERVAL 1 DAY)
       ) vc
    ON vc.post_id = p.post_id
;

With the counts in the temporary table, we can update post table...

UPDATE post t
  JOIN `__post_last_day_counts__` s
    ON s.post_id = t.id
   SET t.likes_last_day = s.likes_last_day
     , t.views_last_day = s.views_last_day
;

And cleanup...

DROP TEMPORARY TABLE IF EXISTS `__post_last_day_counts__`
;

Overall this is probably slower, but it may minimize the amount of time that the UPDATE statement holds locks.

NOTE: datatype of the post_id column in the temporary table should match the datatype of post_id in the post table.  I just took a guess.

We are assuming that post_id is the primary key (or unique key) of post table.

Make sure suitable indexes are available:

... on post_view (post_id, date)
... on post_like (post_id, date)

Use EXPLAIN to see execution plan, which operations are being performed and which indexes are being used. (We want to see "Using index for group" in the Extra column.)


问:
Finding a more elegant regex solution
I have a question about a regular expression (I apologize in advance if there are mistakes in the terminology, my course isn't in English):

I wish to write a regular expression for all the strings that contain an even number of the substring 'ab', given that the letters are from the set {a,b,c}.

for example: abab cbcabbcababcab cabcab baccbccabccabc etc.

So far this is the shortest expression I came up with:
(b+a*c+aa*bb*(a+cb*)*ab)*a*

However, this seems a little convoluted, perhaps someone could suggest a shorter or more elegant expression? Thank you.

答:
This isn't necessary more elegant but it doesn't rely on c & should work with any letters.  However, I'll leave that decision up to you, here's my solution:

```<code>^((?!ab).)*(ab((?!ab).)*ab((?!ab).)*)*$
</code>```

Here's an example on regexr!

Title: Finding a more elegant regex solution

Body:
This isn't necessary more elegant but it doesn't rely on c & should work with any letters.  However, I'll leave that decision up to you, here's my solution:

^((?!ab).)*(ab((?!ab).)*ab((?!ab).)*)*$

Here's an example on regexr!


问:
Excel - use a formula to generate cell reference within a formula
I have a table of data - basically with suppliers names along the top, work types down the side and the margins we make from using each supplier to deliver the work type.

On a seperate sheet I want the user to be able to type or select a work type and it to deliver the supplier which gives the maximum margin for the work type and the associated margin.

I have used the following margin and it gives me the right answer

```<code>=INDEX('Master SOR YR5'!CT8:GA8,MATCH(MAX('Master SOR YR5'!CT12:GA12),'Master SOR YR5'!CT12:GA12,0))&" - "&ROUND(INDEX('Master SOR YR5'!CT12:GA12,MATCH(MAX('Master SOR YR5'!CT12:GA12),'Master SOR YR5'!CT12:GA12,0)),4)*100&"%"
</code>```

However, this is limited to one worktype in row 12. Depending on what work type is entered, the row reference will obviously change - how can I make it work? I was thinking of somehow replacing the 12 with a vlookup which returns the row number =(VLOOKUP(B7,'Master SOR YR5'!A12:D100000,4)*1+11)

But I can't see how to embed the vlookup within the Index formula and get to to work.

Any ideas?

答:
You would replace your range in the MATCH with another INDEX/MATCH.

Replace all

```<code>'Master SOR YR5'!CT12:GA12
</code>```

With

```<code>INDEX('Master SOR YR5'!CT:GA,MATCH(B7,'Master SOR YR5'!A:A,0),0)
</code>```

This will return the proper row to the formula for further disection.

Body:
I have a table of data - basically with suppliers names along the top, work types down the side and the margins we make from using each supplier to deliver the work type.

On a seperate sheet I want the user to be able to type or select a work type and it to deliver the supplier which gives the maximum margin for the work type and the associated margin.

I have used the following margin and it gives me the right answer

=INDEX('Master SOR YR5'!CT8:GA8,MATCH(MAX('Master SOR YR5'!CT12:GA12),'Master SOR YR5'!CT12:GA12,0))&" - "&ROUND(INDEX('Master SOR YR5'!CT12:GA12,MATCH(MAX('Master SOR YR5'!CT12:GA12),'Master SOR YR5'!CT12:GA12,0)),4)*100&"%"

However, this is limited to one worktype in row 12. Depending on what work type is entered, the row reference will obviously change - how can I make it work? I was thinking of somehow replacing the 12 with a vlookup which returns the row number =(VLOOKUP(B7,'Master SOR YR5'!A12:D100000,4)*1+11)

But I can't see how to embed the vlookup within the Index formula and get to to work.

Any ideas?

Body:
You would replace your range in the MATCH with another INDEX/MATCH.

Replace all

'Master SOR YR5'!CT12:GA12

With

INDEX('Master SOR YR5'!CT:GA,MATCH(B7,'Master SOR YR5'!A:A,0),0)

This will return the proper row to the formula for further disection.


问:
How do I update an SQL table from an excel spreadsheet?
I have an excel spreadsheet with 2 columns and 1000 rows. I need to update a table an SQL with the data. I basically need it updates the column B values for the adjacent values from column A. How would I go about doing this?</p>

答: You can use the SQL Server Import and Export Wizard. You can feed it comma delineated files and if the first row has the column names. It will do just about everything for you.


问:
Applying greyscale effects to images - Photoshop CC 2017
The image below has a kind of faded grey look with what seems to be some slight blurring and works quite well as a generic banner image.

Usually I am provided with these images or just find stock images but I'd be very interested in learning how to apply these effects with Photoshop or CSS. I have a feeling that Photoshop is a more appropriate tool.

The image I'm experimenting with is this:

It isn't the best image but for my testing purposes at least it's a similar shape and size.

I know I can use things like de-saturation or a coloured layer with a colour blend mode for this sort of thing. However, does the first image look like it has a specific effect or is it just a case of trial and error?

I appreciate this is similar to this question.

答: open your image in photoshop, add a new layer on top of the image, fill the layer with a color of your choice (in this case grey/black) then reduce the opacity of the layer. You will get something similar to what you want. This is a simple trick. It can be done in other ways too with more modifications.</p>


问:
WELD Classloading issue after adding deltaspike to an existing primefaces maven project
I am new to primefaces and deltaspike, we initially tried with CDI conversations but had to fall back to deltaspike. I added the jars as mentioned in the https://deltaspike.apache.org/documentation/configure.html#config-maven-indep  But I am getting a classloading issue with FacesMessages. I am not sure how to resolve this. Below are the logs and pom files.

```<code>11:05:14,056 WARN  [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class javax.faces.application.FacesMessage in Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base)): java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.jboss.weld.annotated.slim.backed.SecurityActions.getDeclaredMethods(SecurityActions.java:41)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:194)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:188)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:156)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:63)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:44)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:74)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:113)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.createContext(FastAnnotatedTypeLoader.java:102)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:81)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
</code>```

11:05:14,065 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000119: Not generating any bean definitions from org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeFacesContextWrapper because of underlying class loading error: Type [unknown] not found.  If this is unexpected, enable DEBUG logging to see the full error.

```<code>11:05:15,468 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."paris-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."paris-ear.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code>```

Caused by:

```<code>org.jboss.weld.exceptions.DeploymentException: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createProducersAndObservers(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:401)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    ... 3 more
</code>```

Caused by:

```<code>java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:30)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:22)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.util.reflection.Reflections.getNonPrivateNonStaticFinalMethod(Reflections.java:177)
    at org.jboss.weld.util.Proxies.getUnproxyableClassException(Proxies.java:218)
    at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:180)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesExceptionInt(Proxies.java:192)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesException(Proxies.java:174)
    at org.jboss.weld.util.Proxies.isTypesProxyable(Proxies.java:162)
    at org.jboss.weld.bean.ProducerMethod.<init>(ProducerMethod.java:76)
    at org.jboss.weld.bean.ProducerMethod.of(ProducerMethod.java:60)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethod(AbstractBeanDeployer.java:214)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethods(AbstractBeanDeployer.java:199)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createObserversProducersDisposers(AbstractBeanDeployer.java:176)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:106)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
</code>```

I understand that this is the root cause

  java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"

  This is the content of my modules.xml under C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base\javax\faces\api\main and it also have my jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar

<module xmlns="urn:jboss:module:1.3" name="javax.faces.api">
  <dependencies>
    <module name="com.sun.jsf-impl" />
    <module name="javax.enterprise.api" export="true" />
    <module name="javax.servlet.api" export="true" />
    <module name="javax.servlet.jsp.api" export="true" />
    <module name="javax.servlet.jstl.api" export="true" />
    <module name="javax.validation.api" export="true" />
    <module name="org.glassfish.javax.el" export="true" />
    <module name="javax.api" />
  </dependencies>

  <resources>
    <resource-root path="jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar" />
  </resources>
</module>```
</div>
</div>
</p>

<hr>

<p>This is the snippet from my ejb module pom.xml</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.primefaces</groupId>
  <artifactId>primefaces</artifactId>
</dependency></code>```

Below is the snippet from Parent pom

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  <version.javaee7.web.spec>7.0</version.javaee7.web.spec>
  <version.jboss-servlet-api_3.1_spec>1.0.0.Final</version.jboss-servlet-api_3.1_spec>
  <version.cdi-api>1.2</version.cdi-api>
  <version.jboss-ejb-api>1.0.0.Final</version.jboss-ejb-api>

  <version.jsf>2.2.12</version.jsf>
  <version.javax.inject>1</version.javax.inject>
  <version.el-api>2.2.1</version.el-api>
  <version.validation>1.1.0.Final</version.validation>
  <version.primefaces>6.0</version.primefaces>
  <version.primefaces.extensions>6.0.0</version.primefaces.extensions>
  <version.themes>1.0.10</version.themes>

  <version.hibernate-entitymanager>5.0.9.Final</version.hibernate-entitymanager>
  <version.hibernate-core>5.0.9.Final</version.hibernate-core>
  <version.hibernate.validator>5.2.4.Final</version.hibernate.validator>
  <version.hibernate-jpa>1.0.0.Final</version.hibernate-jpa>
  <version.hibernate-annotation>3.5.6-Final</version.hibernate-annotation>
  <version.hibernate-commons-annotation>4.0.5.Final</version.hibernate-commons-annotation>

  <version.commons-collections>3.2.2</version.commons-collections>
  <version.commons-lang>2.6</version.commons-lang>
  <version.commons-lang3>3.3</version.commons-lang3>

  <version.commons-config>1.10</version.commons-config>
  <version.common-beanutils>1.9.2</version.common-beanutils>
  <version.common-email>1.4</version.common-email>
  <version.common-exec>1.3</version.common-exec>

  <version.commons-fileupload>1.3</version.commons-fileupload>

  <version.commons-codec>1.10</version.commons-codec>

  <version.poi>3.12</version.poi>

  <version.joda-time>2.8.1</version.joda-time>
  <version.ojdbc6>12.1.0.2</version.ojdbc6>
  <version.dom4j>1.6.1</version.dom4j>
  <version.jxl>2.6.12</version.jxl>
  <version.xerces>2.11.0</version.xerces>

  <version.javaassist>3.15.0-GA</version.javaassist>
  <version.picketbox>4.0.7.Final</version.picketbox>
  <resteasy.version>2.3.5.Final</resteasy.version>
  <version.jgroups>3.6.4.Final</version.jgroups>
  <version.jbosscache>3.2.11.GA</version.jbosscache>

  <version.weldcore>3.0.0.Alpha6</version.weldcore>
  <version.common-jxpath>1.3-redhat-3</version.common-jxpath>

  <version.javamail>1.5.4</version.javamail>

  <version.logback>1.1.5</version.logback>
  <version.slf4j>1.7.16</version.slf4j>

  <version.junit>4.12</version.junit>
  <version.easymock>3.1</version.easymock>

  <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>

  <deltaspike.version>1.7.2</deltaspike.version>
</properties>

<dependencyManagement>
  <dependencies>
    ...
    <dependency>
      <groupId>org.jboss.spec.javax.faces</groupId>
      <artifactId>jboss-jsf-api_2.2_spec</artifactId>
      <version>${version.jsf}</version>
    </dependency>

  </dependencies>
</dependencyManagement>
```

I wanted to attach my complete pom.xml files but didn't know how to do it, they are too big to add them like the modules.xml I did above. Can someone guide me please?

答: After I commented out the javax.faces.application.FacesMessage and all its occurrences from my controllers and service classes, the error disappeared. It looks like we cannot use deltaspike and jsf-api FacesMessage together as they create ambiguity? </p>

Body:
I am new to primefaces and deltaspike, we initially tried with CDI conversations but had to fall back to deltaspike. I added the jars as mentioned in the https://deltaspike.apache.org/documentation/configure.html#config-maven-indep  But I am getting a classloading issue with FacesMessages. I am not sure how to resolve this. Below are the logs and pom files.

11:05:14,056 WARN  [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class javax.faces.application.FacesMessage in Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base)): java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.jboss.weld.annotated.slim.backed.SecurityActions.getDeclaredMethods(SecurityActions.java:41)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:194)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:188)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:156)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:63)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:44)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:74)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:113)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.createContext(FastAnnotatedTypeLoader.java:102)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:81)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

11:05:14,065 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000119: Not generating any bean definitions from org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeFacesContextWrapper because of underlying class loading error: Type [unknown] not found.  If this is unexpected, enable DEBUG logging to see the full error.

11:05:15,468 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."paris-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."paris-ear.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by:

org.jboss.weld.exceptions.DeploymentException: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createProducersAndObservers(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:401)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    ... 3 more

Caused by:

java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:30)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:22)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.util.reflection.Reflections.getNonPrivateNonStaticFinalMethod(Reflections.java:177)
    at org.jboss.weld.util.Proxies.getUnproxyableClassException(Proxies.java:218)
    at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:180)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesExceptionInt(Proxies.java:192)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesException(Proxies.java:174)
    at org.jboss.weld.util.Proxies.isTypesProxyable(Proxies.java:162)
    at org.jboss.weld.bean.ProducerMethod.<init>(ProducerMethod.java:76)
    at org.jboss.weld.bean.ProducerMethod.of(ProducerMethod.java:60)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethod(AbstractBeanDeployer.java:214)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethods(AbstractBeanDeployer.java:199)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createObserversProducersDisposers(AbstractBeanDeployer.java:176)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:106)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)

I understand that this is the root cause

  java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"

  This is the content of my modules.xml under C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base\javax\faces\api\main and it also have my jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar

<module xmlns="urn:jboss:module:1.3" name="javax.faces.api">
  <dependencies>
    <module name="com.sun.jsf-impl" />
    <module name="javax.enterprise.api" export="true" />
    <module name="javax.servlet.api" export="true" />
    <module name="javax.servlet.jsp.api" export="true" />
    <module name="javax.servlet.jstl.api" export="true" />
    <module name="javax.validation.api" export="true" />
    <module name="org.glassfish.javax.el" export="true" />
    <module name="javax.api" />
  </dependencies>

  <resources>
    <resource-root path="jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar" />
  </resources>
</module>

This is the snippet from my ejb module pom.xml

<dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.primefaces</groupId>
  <artifactId>primefaces</artifactId>
</dependency>

Below is the snippet from Parent pom

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  <version.javaee7.web.spec>7.0</version.javaee7.web.spec>
  <version.jboss-servlet-api_3.1_spec>1.0.0.Final</version.jboss-servlet-api_3.1_spec>
  <version.cdi-api>1.2</version.cdi-api>
  <version.jboss-ejb-api>1.0.0.Final</version.jboss-ejb-api>

  <version.jsf>2.2.12</version.jsf>
  <version.javax.inject>1</version.javax.inject>
  <version.el-api>2.2.1</version.el-api>
  <version.validation>1.1.0.Final</version.validation>
  <version.primefaces>6.0</version.primefaces>
  <version.primefaces.extensions>6.0.0</version.primefaces.extensions>
  <version.themes>1.0.10</version.themes>

  <version.hibernate-entitymanager>5.0.9.Final</version.hibernate-entitymanager>
  <version.hibernate-core>5.0.9.Final</version.hibernate-core>
  <version.hibernate.validator>5.2.4.Final</version.hibernate.validator>
  <version.hibernate-jpa>1.0.0.Final</version.hibernate-jpa>
  <version.hibernate-annotation>3.5.6-Final</version.hibernate-annotation>
  <version.hibernate-commons-annotation>4.0.5.Final</version.hibernate-commons-annotation>

  <version.commons-collections>3.2.2</version.commons-collections>
  <version.commons-lang>2.6</version.commons-lang>
  <version.commons-lang3>3.3</version.commons-lang3>

  <version.commons-config>1.10</version.commons-config>
  <version.common-beanutils>1.9.2</version.common-beanutils>
  <version.common-email>1.4</version.common-email>
  <version.common-exec>1.3</version.common-exec>

  <version.commons-fileupload>1.3</version.commons-fileupload>

  <version.commons-codec>1.10</version.commons-codec>

  <version.poi>3.12</version.poi>

  <version.joda-time>2.8.1</version.joda-time>
  <version.ojdbc6>12.1.0.2</version.ojdbc6>
  <version.dom4j>1.6.1</version.dom4j>
  <version.jxl>2.6.12</version.jxl>
  <version.xerces>2.11.0</version.xerces>

  <version.javaassist>3.15.0-GA</version.javaassist>
  <version.picketbox>4.0.7.Final</version.picketbox>
  <resteasy.version>2.3.5.Final</resteasy.version>
  <version.jgroups>3.6.4.Final</version.jgroups>
  <version.jbosscache>3.2.11.GA</version.jbosscache>

  <version.weldcore>3.0.0.Alpha6</version.weldcore>
  <version.common-jxpath>1.3-redhat-3</version.common-jxpath>

  <version.javamail>1.5.4</version.javamail>

  <version.logback>1.1.5</version.logback>
  <version.slf4j>1.7.16</version.slf4j>

  <version.junit>4.12</version.junit>
  <version.easymock>3.1</version.easymock>

  <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>

  <deltaspike.version>1.7.2</deltaspike.version>
</properties>

<dependencyManagement>
  <dependencies>
    ...
    <dependency>
      <groupId>org.jboss.spec.javax.faces</groupId>
      <artifactId>jboss-jsf-api_2.2_spec</artifactId>
      <version>${version.jsf}</version>
    </dependency>

  </dependencies>
</dependencyManagement>

I wanted to attach my complete pom.xml files but didn't know how to do it, they are too big to add them like the modules.xml I did above. Can someone guide me please?


问:
Create a new instance of component in Spring Boot/Framework
In my Spring Boot based application I’ve a @Component class that has code similar to this:

```<code>ExecutorService executorService = Executors.newFixedThreadPool(poolSize);

// Start a separate thread for each entry
Map<Long, Future<Integer>> calls = new HashMap<>();

for (MyClass info : list) {
    Callable<Integer> callable = new TableProcessor(info);
    Future<Integer> future = executorService.submit(callable);
    calls.put(info.getId(), future);
}
</code>```

The AutoWiring is not working in the TableProcessor class because (I think) I am creating an instance using ‘new’.  What’s the best way to ‘create a new instance for each entry in my list’?

Note: Adding a ‘Bean’ to Application class won’t work in this case because I want a new instance for each thread.

答:
I had a similar problem and I solved it using the ApplicationContext.

Here's an example because I like to look at code rather than explain things, so maybe it will help someone in the same boat:

First, here's the Spring component that I want to create a new instance of:

```<code>@Component
@Scope("prototype")
public class PopupWindow extends Window{

    private String someVar;

        @PostConstruct
        public void init(){
          //stuff
          someVar="hi";
    }
}
</code>```

Here's the class where I want 2 instances of this Spring component:

```<code>@Component
@Scope("session")
public class MainWindow extends Window{

    private PopupWindow popupWindow1;
    private PopupWindow popupWindow2;

    @Autowired
    private ApplicationContext applicationContext;

        @PostConstruct
        public void init(){
          popupWindow1 = applicationContext.getBean(PopupWindow.class);
          popupWindow2 = applicationContext.getBean(PopupWindow.class);
    }
}
</code>```

In my particular case, I'm using Vaadin + Spring, and these annotations use the Vaadin versions i.e. @SpringComponent and @UIScope instead of @Scope("session"). But the @Scope("prototype") is the same.

Body:
In my Spring Boot based application I’ve a @Component class that has code similar to this:

ExecutorService executorService = Executors.newFixedThreadPool(poolSize);

// Start a separate thread for each entry
Map<Long, Future<Integer>> calls = new HashMap<>();

for (MyClass info : list) {
    Callable<Integer> callable = new TableProcessor(info);
    Future<Integer> future = executorService.submit(callable);
    calls.put(info.getId(), future);
}

The AutoWiring is not working in the TableProcessor class because (I think) I am creating an instance using ‘new’.  What’s the best way to ‘create a new instance for each entry in my list’?

Note: Adding a ‘Bean’ to Application class won’t work in this case because I want a new instance for each thread.

Body:
I had a similar problem and I solved it using the ApplicationContext.

Here's an example because I like to look at code rather than explain things, so maybe it will help someone in the same boat:

First, here's the Spring component that I want to create a new instance of:

@Component
@Scope("prototype")
public class PopupWindow extends Window{

    private String someVar;

        @PostConstruct
        public void init(){
          //stuff
          someVar="hi";
    }
}

Here's the class where I want 2 instances of this Spring component:

@Component
@Scope("session")
public class MainWindow extends Window{

    private PopupWindow popupWindow1;
    private PopupWindow popupWindow2;

    @Autowired
    private ApplicationContext applicationContext;

        @PostConstruct
        public void init(){
          popupWindow1 = applicationContext.getBean(PopupWindow.class);
          popupWindow2 = applicationContext.getBean(PopupWindow.class);
    }
}

In my particular case, I'm using Vaadin + Spring, and these annotations use the Vaadin versions i.e. @SpringComponent and @UIScope instead of @Scope("session"). But the @Scope("prototype") is the same.


问:
css menu naming convention
I'm stuck with a problem. It is good practice to create classnames that are describing. For example, content-nav and widget-area. I've this menu at the top of the site that has the following links:

Home

English (language dependant)

Contact

Sitemap

Terms & conditions

Disclaimer

How would you semantically call such a menu? In previous projects I referred to it as an top-menu, but that name is related to graphical presentation and not good practice in my opinion.

Thanks in advance!

答: My collegue uses the name meta-navigation, which in this case suits best. Or do you guys have any other ideas?

Title: css menu naming convention


问:
Implementing SSL in ASP.NET core with Kestrel
I'm using the preview tooling for ASP.NET Core and VS 2015 that was released in Dec timeframe.

I've followed numerous online examples with how to enable SSL in Kestrel.  None of them worked.

So I tried an option in project called "Enable SSL" and it seems to set a port for me, and works from local host, but doesn't seem to work from elsewhere.

I've also tried .UseKestrel() I have option.UseHttps("ssl.pfx", "password")

Below that I have UseUrls, but it doesn't seem to bind correctly to the ports because my SSL requests.  When I try to issue SSL requests it times out.  I used netstat and it seems like there is no port opened for my specified SSL port.

1)  How do I use UseUrls?  I need both localhost and remote machine access
2)  How do I configure IIS express to allow the https calls?

If anyone has a good reliable way to set this up for VS 2015 in an ASP.NET Core project I would really appreciate it!

Thanks,

James

答:
You're not saying what you have tried so far, so maybe you've tried that already, but you need to:

have a valid certificate that your server will be able to provide to the client

install the nuget package: Microsoft.AspNetCore.Server.Kestrel.Https

change your configure sequence so that it uses Kestrel Https
app.UseKestrelHttps(certificate);

change the url Kestrel is listening to one starting by https://

I used this article a few months back on VS2015: https://www.thesslstore.com/blog/implement-ssl-kestrel-asp-net-core/
I worked fine for me, but maybe there are a few things to adapt with the latest version.


问:
Delete appointments by code
In my scheduler at some point I need to delete all the appointments or clear all the appointments showed in the xtrascheduler to populate it again with my custom method using a datatable.

So I need to clear the view before the load of the new appoinments. Is there something like ActiveView.Appointments.Clear()/Delete() to clear all the appointment collection?

答:
There are a couple of ways to achieve this:

To simply introduce new appointments, call:

TableAdapter.Fill

If you want to remove all the appointments first use this code:

SchedulerStorage.Appointments.DataSource = Nothing

You can then set the DataSource to your new BindingSource to view a different set of appointments.

Title: Delete appointments by code


问:
How to enter different types parameters into function to return one type data?
l want to enter different types parameters (such as:int,float,double,long) into function to return one type data(such as:string).

Here l just wanna make a function to turn different type data to be string data.

答:
Use this:</p>

```<code>    public static <T extends Number> String getString(T element) {
        return element.toString();
    }

System.out.println(getString(new BigInteger("34234523")));
System.out.println(getString(234));
</code>```

Body:
Use this:

    public static <T extends Number> String getString(T element) {
        return element.toString();
    }

System.out.println(getString(new BigInteger("34234523")));
System.out.println(getString(234));


问:
PHP - Allowed memory size of 134217728 bytes exhausted
I have the following code:

```<code><?php
namespace Debug;

function Alert($msg){
   $temp = "<script>alert('".$msg."')</script>";
   echo $temp;
}

function Log($msg){
   $temp = "<script>console.log('".$msg."')</script>";
   echo $temp;
}

function Mail($message, $subject){
   $to = "email@email.com";

   // Sending email
   if(mail($to, $subject, $message)){
       echo 'Your feedback has been sent successfully.';
   } else{
       echo 'Unable to send feedback. Please try again.';
   }
}

?>
</code>```

Different file:

```<code><?php
    $name = $_POST['feedback_name'];
    $email = $_POST['feedback_email'];
    $msg = $_POST['feedback_message'];

    echo $name;
    echo $email;
    echo $msg;

    include 'WebLib.php';

    Debug\Mail($msg, "Feedback");
?>
</code>```

Since I wrote the Mail() function i get this error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes)

答: With the guess it is going into an infinite loop. Update mail($to, $subject, $message) to \mail($to, $subject, $message) and try, since you are namespacing. In PHP function names are case insensitive. \mail(...) will call the global PHP function.

Body:
I have the following code:

<?php
namespace Debug;

function Alert($msg){
   $temp = "";
   echo $temp;
}

function Log($msg){
   $temp = "";
   echo $temp;
}

function Mail($message, $subject){
   $to = "email@email.com";

   // Sending email
   if(mail($to, $subject, $message)){
       echo 'Your feedback has been sent successfully.';
   } else{
       echo 'Unable to send feedback. Please try again.';
   }
}

?>

Different file:

<?php
    $name = $_POST['feedback_name'];
    $email = $_POST['feedback_email'];
    $msg = $_POST['feedback_message'];

    echo $name;
    echo $email;
    echo $msg;

    include 'WebLib.php';

    Debug\Mail($msg, "Feedback");
?>

Since I wrote the Mail() function i get this error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes)


问:
how get multiple value Regex expressions in Java
how to get all word if it has _I, im using "\S_I+\S".

I Have String :
the_B-NP camera_I-NP is_B-VP very_B-ADJP easy_I-ADJP to_B-VP use_I-VP ,_O in_B-PP fact_B-NP on_B-PP a_B-NP recent_I-NP trip_I-NP this_B-NP past_I-NP week_I-NP i_I-NP was_B-VP asked_I-VP to_B-VP take_I-VP a_B-NP picture_I-NP of_B-PP a_B-NP vacationing_I-NP elderly_I-NP group_I-NP ._O

this my code

```<code>Pattern p = Pattern.compile("\\S*_I+\\S*");
    Matcher m = p.matcher(input);
    while(m.find()){
        hasilReg = m.group();
    }
</code>```

after compile i got only one value : group_I-NP
but i would like all word if it has _I

thanks

答:
The group_I-NP  is the last value and you only get this because you reassign the hasilReg value all the time. Add the results to a List<String>:

```<code>String str = "the_B-NP camera_I-NP is_B-VP very_B-ADJP easy_I-ADJP to_B-VP use_I-VP ,_O in_B-PP fact_B-NP on_B-PP a_B-NP recent_I-NP trip_I-NP this_B-NP past_I-NP week_I-NP i_I-NP was_B-VP asked_I-VP to_B-VP take_I-VP a_B-NP picture_I-NP of_B-PP a_B-NP vacationing_I-NP elderly_I-NP group_I-NP ._O ";
Pattern ptrn = Pattern.compile("\\S*_I+\\S*");
Matcher matcher = ptrn.matcher(str);
List<String> lst = new ArrayList<>();
while (matcher.find()) {
    lst.add(matcher.group());
}
System.out.println(lst);
// => [camera_I-NP, easy_I-ADJP, use_I-VP, recent_I-NP, trip_I-NP, past_I-NP, week_I-NP, i_I-NP, asked_I-VP, take_I-VP, picture_I-NP, vacationing_I-NP, elderly_I-NP, group_I-NP]
</code>```

See the Java demo

Body:
how to get all word if it has _I, im using "\S_I+\S".

I Have String :
the_B-NP camera_I-NP is_B-VP very_B-ADJP easy_I-ADJP to_B-VP use_I-VP ,_O in_B-PP fact_B-NP on_B-PP a_B-NP recent_I-NP trip_I-NP this_B-NP past_I-NP week_I-NP i_I-NP was_B-VP asked_I-VP to_B-VP take_I-VP a_B-NP picture_I-NP of_B-PP a_B-NP vacationing_I-NP elderly_I-NP group_I-NP ._O

this my code

Pattern p = Pattern.compile("\\S*_I+\\S*");
    Matcher m = p.matcher(input);
    while(m.find()){
        hasilReg = m.group();
    }

after compile i got only one value : group_I-NP
but i would like all word if it has _I

thanks

Body:
The group_I-NP  is the last value and you only get this because you reassign the hasilReg value all the time. Add the results to a List<String>:

String str = "the_B-NP camera_I-NP is_B-VP very_B-ADJP easy_I-ADJP to_B-VP use_I-VP ,_O in_B-PP fact_B-NP on_B-PP a_B-NP recent_I-NP trip_I-NP this_B-NP past_I-NP week_I-NP i_I-NP was_B-VP asked_I-VP to_B-VP take_I-VP a_B-NP picture_I-NP of_B-PP a_B-NP vacationing_I-NP elderly_I-NP group_I-NP ._O ";
Pattern ptrn = Pattern.compile("\\S*_I+\\S*");
Matcher matcher = ptrn.matcher(str);
List<String> lst = new ArrayList<>();
while (matcher.find()) {
    lst.add(matcher.group());
}
System.out.println(lst);
// => [camera_I-NP, easy_I-ADJP, use_I-VP, recent_I-NP, trip_I-NP, past_I-NP, week_I-NP, i_I-NP, asked_I-VP, take_I-VP, picture_I-NP, vacationing_I-NP, elderly_I-NP, group_I-NP]

See the Java demo


问:
box-shadow glitch when interacting
I have a vignette on my stock image created with box-shadow. It looks good, but sometimes when I press button that is on top of that vignette or when I select text then it dissapears only in the region of that selection which looks bad.

```<code><div>
    <div class="stock-image flex-container">
      <div class="column">
        <div class="row column">
          <div>
            <h1 class="welcome">Connect with people</h1>
          </div>
         </div>
        </div>
     </div>
</div>
</code>```

Css:

```<code>.stock-image {
    width: 100%;
    height: 32em;
    background: linear-gradient(90deg, rgba(22, 156, 202,0.65), rgba(22, 156, 202,0.45)),#00A7E1 url(../../assets/img/home/stock-image.jpg) no-repeat center center;
    background-size: cover;
    box-shadow: inset 0 0 30em 0.7em #000;
}
</code>```

Sometimes when I select Connect with people it removes shadow inside the selected area and after deselecting it, the shadow is still missing.

Also I cannot just create vignette in photoshop, because the image is visible depending on device's screen size that user uses, so often only part of the image is visible.

EDIT:
As a workaround I used two linear-gradients:

```<code>linear-gradient(to right, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.15) 15%, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.0) 65%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.75) 100%)
linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.15) 15%, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.0) 65%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.75) 100%)
</code>```

It doesn't look as good as I would want, but I guess it's just a matter of tweeking parameters.

答:
You might try addressing Chrome directly in your CSS via  -webkit-box-shadow - e.g.:</p>

```<code>-webkit-box-shadow: 4px 4px 4px 4px rgba(22,156,202,0.65);
box-shadow: 4px 4px 4px 4px rgba(22,156,202,0.65);
</code>```

Title: box-shadow glitch when interacting

Body:
I have a vignette on my stock image created with box-shadow. It looks good, but sometimes when I press button that is on top of that vignette or when I select text then it dissapears only in the region of that selection which looks bad.

Connect with people

Css:

.stock-image {
    width: 100%;
    height: 32em;
    background: linear-gradient(90deg, rgba(22, 156, 202,0.65), rgba(22, 156, 202,0.45)),#00A7E1 url(../../assets/img/home/stock-image.jpg) no-repeat center center;
    background-size: cover;
    box-shadow: inset 0 0 30em 0.7em #000;
}

Sometimes when I select Connect with people it removes shadow inside the selected area and after deselecting it, the shadow is still missing.

Also I cannot just create vignette in photoshop, because the image is visible depending on device's screen size that user uses, so often only part of the image is visible.

EDIT:
As a workaround I used two linear-gradients:

linear-gradient(to right, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.15) 15%, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.0) 65%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.75) 100%)
linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.15) 15%, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.0) 65%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.75) 100%)

It doesn't look as good as I would want, but I guess it's just a matter of tweeking parameters.

Body:
You might try addressing Chrome directly in your CSS via  -webkit-box-shadow - e.g.:

-webkit-box-shadow: 4px 4px 4px 4px rgba(22,156,202,0.65);
box-shadow: 4px 4px 4px 4px rgba(22,156,202,0.65);


问:
SQL Server Insert trigger inserting more than once
My  trigger is for some reason inserting 4 times, and the last one is only being grouped. Basically what I want to do is when information is inserted into my table tbl_delete_Panel I want to group this data and insert the grouping into tbl_delete_panel_Orderin.

```<code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE Trigger[dbo].[deletePanelSQL]
ON [dbo].[tbl_delete_Panel]
AFTER INSERT
AS
BEGIN
     /* Insert Summed Quantity for each stud or track into tbl_delete_panel for deletion. tbl_delete_panel trigger will be triggered */
    INSERT INTO tbl_delete_panel_Orderin (Part_Name, OrderID, SumOfQTY)
       SELECT
           tbl_delete_panel.Part_Name, tbl_delete_panel.OrderID,
           Sum(tbl_delete_panel.QTY) AS SumOfQTY
       FROM
           tbl_delete_panel
       GROUP BY
           tbl_delete_panel.Part_Name, tbl_delete_panel.OrderID;
END;
</code>```

答:
Right now, you keep inserting the complete set of rows from the tbl_delete_panel, every time this trigger is fired.

What you should do instead is look at the Inserted pseudo table which can and will contain multiple rows (so you need to handle that situation, with a nice, proper set-based approach - no cursor, no while loops!) - and insert those rows (that were newly inserted by the statement that caused the trigger to fire) - not the whole table every time !

Try something like this:

```<code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE Trigger[dbo].[deletePanelSQL]
ON [dbo].[tbl_delete_Panel]
AFTER INSERT
AS
BEGIN
     /* Insert summed quantity for each stud or track into tbl_delete_panel for deletion. tbl_delete_panel trigger will be triggered */
    INSERT INTO tbl_delete_panel_Orderin (Part_Name, OrderID, SumOfQTY)
       SELECT
           Part_Name, OrderID,
           Sum(QTY) AS SumOfQTY
       FROM
           Inserted i
       GROUP BY
           Part_Name, OrderID;
END;
</code>```

Body:
My  trigger is for some reason inserting 4 times, and the last one is only being grouped. Basically what I want to do is when information is inserted into my table tbl_delete_Panel I want to group this data and insert the grouping into tbl_delete_panel_Orderin.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE Trigger[dbo].[deletePanelSQL]
ON [dbo].[tbl_delete_Panel]
AFTER INSERT
AS
BEGIN
     /* Insert Summed Quantity for each stud or track into tbl_delete_panel for deletion. tbl_delete_panel trigger will be triggered */
    INSERT INTO tbl_delete_panel_Orderin (Part_Name, OrderID, SumOfQTY)
       SELECT
           tbl_delete_panel.Part_Name, tbl_delete_panel.OrderID,
           Sum(tbl_delete_panel.QTY) AS SumOfQTY
       FROM
           tbl_delete_panel
       GROUP BY
           tbl_delete_panel.Part_Name, tbl_delete_panel.OrderID;
END;

Body:
Right now, you keep inserting the complete set of rows from the tbl_delete_panel, every time this trigger is fired.

What you should do instead is look at the Inserted pseudo table which can and will contain multiple rows (so you need to handle that situation, with a nice, proper set-based approach - no cursor, no while loops!) - and insert those rows (that were newly inserted by the statement that caused the trigger to fire) - not the whole table every time !

Try something like this:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE Trigger[dbo].[deletePanelSQL]
ON [dbo].[tbl_delete_Panel]
AFTER INSERT
AS
BEGIN
     /* Insert summed quantity for each stud or track into tbl_delete_panel for deletion. tbl_delete_panel trigger will be triggered */
    INSERT INTO tbl_delete_panel_Orderin (Part_Name, OrderID, SumOfQTY)
       SELECT
           Part_Name, OrderID,
           Sum(QTY) AS SumOfQTY
       FROM
           Inserted i
       GROUP BY
           Part_Name, OrderID;
END;